【发布时间】:2011-12-05 08:38:05
【问题描述】:
我这样实现了这个自定义的 AlertDialog:
AlertDialog dialog = new AlertDialog.Builder(this)
.setView(dialogView)
.setTitle(getResources().getString(R.string.addedit_asklater_price))
.setCancelable(false)
.create();
dialog.setMessage(text);
dialog.setOwnerActivity(this);
dialog.setButton(...)
dialog.setButton(...)
dialog.show();
doProcessUserInput();
但是,我注意到在dialog.show() 控件立即流向doProcessUserInput() 之后,无需等待用户使用任何对话框按钮关闭对话框。
这种行为看起来很奇怪,我原以为对话框是模态的,就像我一直知道的模态对话框一样。
我可以重组我的代码,以便从对话框按钮的onClickListener 调用doProcessUserInput()。然而,我想知道是否有办法在 dialog.show() 处暂停程序执行,直到对话框结束。
PS:
- 我尝试使用扩展 Dialog 的自定义对话框,但它具有
同样的问题。我正在按钮的
onClickListener。 - 我已经尝试实现
Activity::onCreateDialog并使用showDialog(id)而不是dialog.show(),但这有同样的问题。
【问题讨论】:
标签: android dialog modal-dialog