我想在webview完成加载网页时关闭ProgressDialog,它不适合我。这是我的代码:
package com.mcc.ghurbo;
import java.security.PublicKey;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class GhurboActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
final WebView mywebview=(WebView)findViewById(R.id.webview);
mywebview.getSettings().setJavaScriptEnabled(true);
mywebview.setWebViewClient(new WebViewClient());
final ProgressDialog p=new ProgressDialog(GhurboActivity.this);
p.show(GhurboActivity.this, "", "Loading...");
Thread loading=new Thread(){
public void run(){
try {
mywebview.loadUrl("http://www.google.com");
}
//end of try
catch(Exception e ){
e.printStackTrace();
}// end of catch
finally{
p.dismiss();
}//end of finally
}//end of run
};//end of thread
loading.start();
}
请尽早帮助我。我无法解决这个问题而继续我的工作
答案 0 :(得分:0)
尝试以下方法以使用webView显示进度对话框
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// Start PROGRESS DIALOG
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
//HIDE PROGRESS DIALOG LOADING IT HAS FINISHED
}
});
肯定会帮助你