Usama Sarwar
Usama Sarwar

Reputation: 9020

Remove process dialog when page starts loading?

I am using a webview in an application and currently when webview starts, a dialog appears showing "please wait, loading" and remains there on screen until every single dot on the web page is loaded. which obviously makes it seem working too slow. Now i want is to dismiss the dialog when webview has something on it and remaining may keep on loading, so that app may become a little more responsive. what should i do....????

Upvotes: 0

Views: 226

Answers (1)

Steve Bergamini
Steve Bergamini

Reputation: 14600

Here's a great tutorial on adding a progress bar to the top of your webview:

http://longweekendmobile.com/2011/08/20/custom-progress-view-on-android-webview/

To apply this to your needs, just dismiss the progress dialog prior to the progress reaching 100.

Something like this:

   webview.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
           if(progress >= 50){
              if(progressDialog.isShowing()){
                  progressDialog.dismiss();
              }

           }
        }
    });

Adjust the if statement with 50 to whatever value you want. This code is untested and should just be used to give you the idea.

Upvotes: 1

Related Questions