当 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();
}
请尽早帮助我。如果不解决此问题,我将无法继续我的进一步工作