0
我有一個ListActivity類,當點擊列表中的任何項目時,會顯示一個新的活動。新的活動需要時間來加載,所以我希望用戶知道有事情發生(在進度對話框的形式)Android - 進度對話框不關閉
所以,爲了做到這一點,我實現Runnable接口在我的班級像這樣 -
public class ProtocolListActivity extends ListActivity implements Runnable {
private ProgressDialog progDialog;
....
protected void onListItemClick(ListView l, View v, int position, long id) {
progDialog.show(this, "Showing Data..", "please wait", true, false);
Thread thread = new Thread(this);
thread.start();
}
....
public void run() {
// some code to start new activity based on which item the user has clicked.
}
最初,當我點擊,並且正在加載的新的活動,進度對話框工作得很好,但是當我關閉之前的活動(要回這個名單)進度對話框仍在運行。我希望進度對話框僅在新活動開始時顯示。
有人可以請指導我如何正確地做到這一點。