我想從服務器獲取一些數據。如果由於某些原因導致中間失敗,我顯示一條警告提示用戶再次重新開始下載。所以我所做的是,在alert對話框的ok按鈕中,我再次調用了下載方法。這使警報對話框凍結並停止形成隱藏。只有下載完成後,警報對話框纔會被解除。任何人都可以在這裏提出一些想法如何手動關閉alertDialog?
0
A
回答
0
onclick事件首先關閉對話框(dialog.cancel();或dialog.dismiss() ),然後再次調用下載函數。 使用此代碼獲取對話框showDialog(0);
protected Dialog onCreateDialog(int id)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this); //builder to create dialog
switch(id)
{
case 0:
if(GAME_STARTED)
{
builder.setTitle("failed");
builder.setMessage("xxxxx");
//The buttons set for the dialog box
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
builder.dismiss();
download_again();
}});
}
break;
default:
}
return builder.create();
}
+0
這不是自定義對話框。這是一個AlertDialog。沒有像cancel()或dismiss()這樣的方法。 –
+0
看到這個http://stackoverflow.com/questions/4336470/how-do-i-close-an-android-alertdialog –
相關問題
- 1. 如何自動關閉alertdialog
- 2. 如何關閉AlertDialog?
- 3. 如何關閉Android alertdialog
- 4. 如何防止AlertDialog關閉?
- 5. 如何關閉jgrowl手動
- 6. 如何手動關閉UAModalPanel
- 7. 關閉AlertDialog框
- 8. AlertDialog不關閉xamarin
- 9. Android AlertDialog force關閉
- 10. 如何在alertdialog關閉後刷新edittext
- 11. 如何在FlatButton單擊中關閉AlertDialog?
- 12. 如何讓搜索按鈕關閉AlertDialog?
- 13. 如何不關閉AlertDialog的Android
- 14. 如何用鼠標點擊關閉AlertDialog?
- 15. 防止AlertDialog自動關閉NeutralButton點擊???
- 16. 無法完全關閉alertdialog
- 17. 如何啓動硒瀏覽器並手動關閉它?
- 18. 當應用程序關閉時關閉AlertDialog內部適配器
- 19. 關閉沒有按鈕的AlertDialog
- 20. 關閉clicklistener上的自定義alertdialog
- 21. 無法在onResume()後關閉AlertDialog()
- 22. 如何關閉AlertDialog當我點擊ListView項
- 23. android:timer:手機關閉
- 24. java okhttp手動關閉連接問題
- 25. jQuery:手動關閉對話框
- 26. 手動啓用和關閉notificationListenerService
- 27. 用滑動手勢關閉HamburgerMenu
- 28. 手動關閉Jquery對話窗口
- 29. J2me:Displayable.setTicker()自動關閉諾基亞手機
- 30. 如何自動關閉InfoWindows
請添加一些代碼示例。我想你應該先關閉對話框然後開始下載。而不是相反。 – powerMicha