为什么setCanceledOnTouchOutside(假)不报警建设者工作? [英] why setCanceledOnTouchOutside(false) doesn't work in Alert builder?

查看:201
本文介绍了为什么setCanceledOnTouchOutside(假)不报警建设者工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的活动的警告对话框,并且不希望用户可以通过单击该对话框外的驳回。根据我的研究(这样)我发现 setCanceledOnTouchOutside(假); 方法。不过,我不能在我的应用程序中使用它,它是可能的解雇对话框,而我有这个方法。

I have an alert dialog in my activity and don't want user can dismiss it by clicking outside of the dialog. Based on my research (like this) I found setCanceledOnTouchOutside(false); method. However, I couldn't use it in my application and it is possible to dismiss dialog while I have this method.

这是我的code:

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:
        }
}
});

任何建议将AP preciated。

any suggestion would be appreciated.

推荐答案

这是一个有趣的问题,我想我知道你的答案。

This is an interesting question and I think I know your answer.

我已被被测试在不同平台上的应用程序,我注意到它们之间的小的差异。上面,当你触摸敬酒消息的Andr​​oid 4.0,它只是消失。我quess它与对话(和AlertDialogs)相同。它只是消失触摸时(但它没有被驳回 - 只是无法看到)。

I have been testing an application on different platforms and I noticed a small difference between them. Above android 4.0 when you touch a Toast message, it simply disappears. I quess it is the same with dialogs (and AlertDialogs). It simply "disappears" when touching (but it is not dismissed! - just cannot be seen).

希望它帮助!

这篇关于为什么setCanceledOnTouchOutside(假)不报警建设者工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆