2012-04-10 33 views
0

我有進度進度動作週期的Android

ProgressDialog.show(this, "VVV","DDD", false,true,new DialogInterface.OnCancelListener() 
     { 
      public void onCancel(DialogInterface dialog) 
      { 
       //msgDisplay("Action is cancelled"); 
      } 
     }); 

這段代碼如何綁定此代碼,我做任何動作?

例如:

1. i press the button 
2. this progressbar will work 
3. i run my function for doing something 
4. when my function ends the progressbar will ends 
+0

您可以輕鬆地用[Android-AsyncTask](http://developer.android.com/reference/android/os/AsyncTask.html)完成同樣的事情。正如你在步驟中所提到的。 – user370305 2012-04-10 07:31:53

+0

我想現在這個問題是沒用的。你知道這個答案... – 2012-04-11 14:26:31

回答

1

其實你只需要實現在你的代碼AsyncTask

  1. 只是在onPreExecute()方法中包含ProgressBar。
  2. doInBackground()方法中執行您的後臺任務。對於例如我運行我的功能做
  3. 忽略onPostExecute()方法中的ProgressBar。
+0

謝謝你的幫助,你能幫我一個小樣嗎?我在android上新增了.... – Gold 2012-04-10 07:44:53

+0

您可以查看[參考資料](http://www.technotalkative.com/loading-remote-images/)這個例子。 – 2012-04-10 08:48:24