我有一个activity
在启动时显示ProgressDialog
,当WebView
上的页面加载完毕后,它会消失。我在onPageFinished
和progbar.dissmiss()
上登录,但只有日志正在运行且ProgressBar
仍然存在。我的代码是这样的:
ProgressDialog progbar;
progbar = ProgressDialog.show(SchoolActivity.this, "", "Loading...");
wv.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(wv, link);
Log.d("log","Finished!!!");
progbar.dismiss();
}
}
});
wv.loadUrl(link); //"wv" is the webview and "link" is the url
答案 0 :(得分:1)
这对我有用:
private void initializeWebView() {
// fix weird recursive-loop bug in WebView
final ProgressDialog dialog = new ProgressDialog(Activity.this);
dialog.setMessage("Please wait while the form is loading...");
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.show();
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
dialog.dismiss();
}
});
}