2012-04-05 177 views
0

我有AsynTask,並取得進展dialoge在運行時。電話接聽來電。呼叫停止後,進度對話框不顯示,但如果顯示對話框,則活動佈局將以這種方式變暗。你有什麼想法嗎?安卓:沒有顯示ProgressDialog

我有事端這樣的:

Recovery recovery=new Recovery(); 
recovery.execute(); 

而且asynktask:

public class Recovery extends AsyncTask<String, Void, Integer>{ 
     @Override 
     protected Integer doInBackground(String... uri) { 
      publishProgress(); 
      //some code 
      return Ret; 
     } 
     @Override 
     protected void onProgressUpdate(Void... values) { 
      super.onProgressUpdate(values); 
      showDialog(RECOVERY); 
     } 
     @Override 
     protected void onPostExecute(Integer result) { 
      super.onPostExecute(result); 
      dismissDialog(RECOVERY); 
     } 
    } 
+0

你介意我們展示一些代碼? – keyboardsurfer 2012-04-05 11:57:50

回答

0

使用這種方式它的工作原理

ProgressDialog dialog = new ProgressDialog(YourActivity.this); 

    @Override 
    protected void onPreExecute() 
    { 
     this.dialog.setMessage("Loading Please Wait..."); 
     this.dialog.show() 
    } 



    @Override 
    protected void onPostExecute(Integer result) { 
     super.onPostExecute(result); 
     if (this.dialog.isShowing()) { 
       this.dialog.dismiss(); 
      } 
    }