【发布时间】:2012-11-11 16:15:27
【问题描述】:
我的活动中有一个警报对话框,不希望用户通过单击对话框外部来关闭它。根据我的研究 (like this),我发现了 setCanceledOnTouchOutside(false); 方法。但是,我无法在我的应用程序中使用它,并且可以在使用此方法时关闭对话框。
这是我的代码:
private AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.setTitle("");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (intAlertAction) {
case 1:
case 2:
case 3:
default:
}
}
});
任何建议将不胜感激。
【问题讨论】:
标签: android dialog android-alertdialog