Android: Show Progress bar when page take load Webview

Hello Guys I want to show progress bar when user open page
Here is .JAVA


import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

    private WebView mWebView;

    protected void onCreate(Bundle savedInstanceState) {

        mWebView = (WebView) findViewById(;

        // Force links and redirects to open in the WebView instead of in a browser
        mWebView.setWebViewClient(new WebViewClient());

        // Enable Javascript
        WebSettings webSettings = mWebView.getSettings();

        // Use remote resource

        // Stop local links and redirects from opening in browser instead of WebView
        mWebView.setWebViewClient(new MyAppWebViewClient());

        // Use local resource
      //   mWebView.loadUrl("file:///src/main/assets/www/index.php");

    // Prevent the back-button from closing the app
    public void onBackPressed() {
        if(mWebView.canGoBack()) {
        } else {

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == {
            return true;

        return super.onOptionsItemSelected(item);


<RelativeLayout xmlns:android=""
    xmlns:tools="" android:layout_width="match_parent"

        android:layout_height="match_parent" />


Like this

So there is many ways you can do this but the easiest is using a ProgressDialog. Open the progressdialog before your web view is loaded and then hide when done.

I would also suggest on creating a class that extends AsyncTask so you can then use the on preExecute and postExecute events for the loading of your webview and allowing pre and post events for your progress dialog.

I’m not sure but I think you can use Progress Dialog before web page is loaded.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.