2012-02-02 200 views
-1

我想在我的活動中顯示progressDialog時,我調用webservices和調用web服務結束對話框自動解除任何知道如何做到這一點,我想爲它的一些示例。 Thankx提前。如何在Android中顯示progressDialog?

這裏是我的代碼,但它不工作的罰款

final ProgressDialog dialog = ProgressDialog.show(
       RouteServicing.this, "", "Loading. Please wait...", true); 

     final Handler handler = new Handler() { 
      public void handleMessage(Message msg) { 
       dialog.dismiss(); 
      } 
     }; 

     Thread checkUpdate = new Thread() { 
      public void run() { 

       Status = cn.callWebService(url); 
       getDetail(Status); 
       //handler.sendEmptyMessage(0); 
       dialog.dismiss(); 
      } 
     }; 
     checkUpdate.start(); 

它表明我這個錯誤

02-02 16:06:53.219: E/WindowManager(1127): android.view.WindowLeaked: Activity com.palewar.coinop.RouteServicing has leaked window [email protected] that was originally added here 
02-02 16:06:53.219: E/WindowManager(1127): at android.view.ViewRoot.<init>(ViewRoot.java:272) 
02-02 16:06:53.219: E/WindowManager(1127): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148) 
02-02 16:06:53.219: E/WindowManager(1127): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 
02-02 16:06:53.219: E/WindowManager(1127): at android.view.Window$LocalWindowManager.addView(Window.java:424) 
02-02 16:06:53.219: E/WindowManager(1127): at android.app.Dialog.show(Dialog.java:241) 
02-02 16:06:53.219: E/WindowManager(1127): at android.app.ProgressDialog.show(ProgressDialog.java:107) 
02-02 16:06:53.219: E/WindowManager(1127): at android.app.ProgressDialog.show(ProgressDialog.java:90) 
02-02 16:06:53.219: E/WindowManager(1127): at com.palewar.coinop.RouteServicing.onClick(RouteServicing.java:243) 
+1

什麼不起作用?有關細節的更多信息不要太模糊。 – JoxTraex 2012-02-02 10:33:33

+0

你在哪裏調用'show()'? – rds 2012-02-02 10:35:49

回答

1

你沒有正確編碼。 只是結帳如何正確地在我的答案here

1

改變方法:

Thread checkUpdate = new Thread() { 
      public void run() { 

       Status = cn.callWebService(url); 
       getDetail(Status); 
       handler.sendEmptyMessage(0); 
      } 
     }; 
+0

可以告訴我,我需要改變上述方法。 – 2012-02-02 11:05:09