Reputation: 1402
I have used progress bar to indicate page is loading in android webview. But the Progress Bar is showing for ever even after the page has been loaded completely. I used logcat for debugging which shows onPageFinished function is called.
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
_dialog =ProgressDialog.show(UmlScreen.this, "", "Please wait...");
super.onPageStarted(view, url, favicon);
_dialog.setCanceledOnTouchOutside(true);
Log.d("LOGCAT", "started");
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
if (_dialog != null || _dialog.isShowing()) {
_dialog.dismiss();
Log.d("LOGCAT", "finished");
}
}
Upvotes: 1
Views: 1983
Reputation: 1888
@Override
public void onPageFinished(WebView view, String url) {
try{
if (prDialog.isShowing()|| prDialog!= null) {
prDialog.dismiss();
prDialog= null; /*** Add ***/
}
}catch(Exception exception){
exception.printStackTrace();
}
}
}
Or visit... https://stackoverflow.com/a/31981161/3857542
Upvotes: 0
Reputation: 7350
I can give you some dummy codes.
webview.load(url);
dialog.show();
public void onPageFinished(WebView view, String url) {
//....
dialog.dismiss();
}
Upvotes: 0
Reputation: 4348
Because the page is not finished. May be the page have a lot of images so it is taking time to download them.
you can check it using break point. debug you code and put break point at super.onPageFinished(view, url);
Upvotes: 0
Reputation: 18112
Try initialization of _dialog outside WebViewClient such as in OnCreateView method
Upvotes: 3