【发布时间】:2012-05-01 18:50:41
【问题描述】:
我编写了以下代码来显示 AlertDialogBox,如下所示
private void dispAlertBox(final String title,final String message,final String ok,final String cancel){
final AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
try{
alertbox.setMessage(message);
alertbox.setTitle(title);
alertbox.setPositiveButton(ok,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface arg0, int arg1){
}
});
alertbox.setNegativeButton(cancel,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface arg0, int arg1){
}
});
alertbox.show();
}catch(Exception e){
//Handle BadTokenException.
}
}
在上面我想在单击确定并取消时关闭 AlertDialog。因此,如果我们单击除 AlertDialog(确定并取消)以外的任何其他区域,它不应该关闭。它工作正常2.x 版本的 Android。但在 Android 4.0 中,即使我们单击 ok 和取消按钮以外的空白区域,对话框也会关闭。我该如何克服这个问题。
谢谢&问候,
文卡特。
【问题讨论】:
标签: android android-alertdialog