我正在製作一個web視圖,並試圖顯示使用進度加載消息Dialog.progress對話框顯示,但不是在URL的所有內容加載後解僱。請幫助我。ProgressDialog不是解僱
mWebview = new WebView(this);
mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
final Activity activity = this;
mWebview.setWebViewClient(new WebViewClient() {
ProgressDialog prDialog;
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
prDialog = ProgressDialog.show(Web.this, null, "loading, please wait...");
super.onPageStarted(mWebview, url, favicon);
Toast.makeText(getApplicationContext(), "started!"+1, Toast.LENGTH_SHORT).show();
num++;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(mWebview, url);
prDialog.dismiss();
Toast.makeText(getApplicationContext(), "Done!", Toast.LENGTH_SHORT).show();
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
});
mWebview .loadUrl("http://www.google.com");
setContentView(mWebview);
'onPageFinished'被調用嗎?你看到「完成」烤麪包了嗎? –
是... @ jason g peterson –
是的,它顯示「完成」吐司消息。 –