在程序中使用webview視圖顯示html頁面。我想在頁面加載時顯示一個進度對話框。但是我加載頁面後,沒有顯示進度對話框。我使用AsyncTask,進度對話框還是沒有顯示。我使用的以下代碼:
class DownloadAysnc extends AsyncTask<String, String, Void>
{
ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(OverView.this, "", "Please Wait ...");
}
@Override
protected Void doInBackground(String... arg0) {
webView.loadUrl("http://marico.com/html/investor/overview.php");
return null;
}
@Override
protected void onPostExecute(Void result){
super.onPostExecute(result);
progressDialog.dismiss();
}
}
如果我使用google文檔顯示web頁面,html tag能顯示,但是html頁面不顯示。下面的代碼
String url = "http://google.co.in/";
String googleDocsUrl = "http://docs.google.com/viewer?url="+url;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(googleDocsUrl ), "text/html");
startActivity(intent);
this.myWebView.loadUrl(googleDocsUrl);
請求大家的幫忙。
webView.setWebViewClient(new WebViewClient() {
ProgressDialog prDialog;
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
prDialog = ProgressDialog.show(Activity.this, null, "loading, please wait...");
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
prDialog.dismiss();
super.onPageFinished(view, url);
}
});
webView.loadUrl(url);