-1

我有一个在启动时activity显示的,当页面完成加载时它应该消失。我在上面放了一个日志,但只有日志在工作,并且仍然在那里。我的代码是这样的:ProgressDialogWebViewonPageFinishedprogbar.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
4

1 回答 1

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();
           }
        });
}
于 2012-08-30T07:09:14.443 回答