开发者

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 th开发者_StackOverflow社区at app may become a little more responsive. what should i do....????


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜