![](/img/trans.png)
[英]When does touching the screen outside an AlertDialog cancel the AlertDialog?
[英]Cancel an AlertDialog when screen is rotated
我在應用程序上顯示了AlertDialog.Builder。 旋轉屏幕時,出現“應用程序窗口泄漏”錯誤。 如何在onPause()事件中取消AlertDialog? 我看不到Ad.cancel()的任何方法。
更新 :為工作模型編輯了代碼。
private AlertDialog inputDlg;
...
@Override
protected void onPause ()
{
// close dialog if it's showing
if (inputDlg != null)
if (inputDlg.isShowing ())
inputDlg.dismiss ();
super.onPause ();
}
...
private void dlgUserPrompt (Context c)
{
// Set an EditText view to get user input
final EditText input = new EditText (c);
AlertDialog.Builder Ab = new AlertDialog.Builder (this);
Ab.setTitle("title");
Ab.setMessage("I won't explode if you rotate this");
Ab.setView(input);
inputDlg = Ab.show ();
}
我認為您正在尋找解雇方法。
您需要重寫onConfigurationChange()
掛鈎才能執行此操作。 本文檔將幫助您詳細了解什么是配置更改以及如何進行更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.