假设您有一个带有两个按钮 A 和 B 的 AlertDialog
。我发现在某些设备和某些 Android 版本上,如果您触摸对话框周围屏幕的任何区域,AlertDialog
消失。在其他设备上,您必须选择 A 或 B,因此如果不向 AlertDialog
添加第三个(“取消”)选项,我就无法允许用户取消操作。有没有办法以编程方式确定是否需要第三个选项?
最佳答案
您可以通过 dialog.setCanceledOnTouchOutside(true); 来控制它
了解更多信息:
How to dismiss the dialog with click on outside of the dialog?
关于android - 什么时候触摸 AlertDialog 之外的屏幕会取消 AlertDialog?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26993860/