我正在開發我的第一個Androïd應用程序,當我想要顯示ProgressDialog以指示進程正在運行時,我遇到問題。 在我的應用程序中,用戶通過按下按鈕來觸發耗時的任務。當用戶按下按鈕時,我的「OnClickListener」的「OnClick」功能被調用。在此功能中,這裏是目前我在做什麼:主題和ProgressDialog
- creation and configuration of an instance of the ProgressDialog class,
- creation of a thread dedicated to the time consuming task,
- attempt to display the ProgressDialog using the "show" method,
- start of the thread,
- main Activity suspended (call of the "wait" function)
- wake up of the main Activity by the thread when it is finished
- removal of the ProgressDialog by calling the "dismiss" function.
,一切工作正常(長期任務的結果是正確的),但仍然出現ProgressDialog訥韋爾。我究竟做錯了什麼?
在此先感謝您花費時間來幫助我。
使用此方法是否滿足原始發佈者的要求,即暫停主要活動,直到耗時操作完成? – shyamal 2012-06-26 18:34:06
他爲什麼要這麼做? UI線程負責在後臺線程運行時顯示(動畫)進度指示器。 (調用wait()會掛起UI線程,而不是Activity)。如果我正確理解了這個問題,那麼該框不包含他的需求,但是他的解決方案會改爲嘗試。 – user634618 2012-09-06 13:20:54