AlertDialog的setCancelable(假)方法不工作 [英] AlertDialog's setCancelable(false) method not working

查看:2912
本文介绍了AlertDialog的setCancelable(假)方法不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个AlertDialog这是工作的罚款。它正在消失,如果我preSS:
1)逃生键盘按钮或
2)后退按钮使用鼠标
为了让专注即使在上述条件下,我又增加了.setCancelable(假)'语句,同时建立。但是,我仍然看到对话框消失。问题出在哪里? 请大家帮帮忙。照片

I had created an AlertDialog which is working fine. It is disappearing, if I press:
1) escape keyboard button or
2) back button using mouse
To make it stay focused even on above stated conditions, I had added '.setCancelable(false)' statement while building. But, I still see dialog disappearing. Where is the problem? Please help.

code补充说:

Code added:

return new AlertDialog.Builder(getActivity())
                .setIcon(R.drawable.alert_dialog_icon)
                .setTitle(title)
                .setCancelable(false)
                .setPositiveButton(R.string.alert_dialog_ok,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            ((FragmentAlertDialog)getActivity()).doPositiveClick();
                        }
                    }
                )
                .setNegativeButton(R.string.alert_dialog_cancel,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            ((FragmentAlertDialog)getActivity()).doNegativeClick();
                        }
                    }
                )
                .create();


信封:Android 4.0的在XP专业版


Env: Android 4.0 on XP Professional.

推荐答案

是<一个href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentAlertDialog.html">this您完整的code?那么请改变你的code设置 setCancelable(假)像这样

Is this your complete code? then please change your code for setting setCancelable(false) like this

void showDialog() {
    DialogFragment newFragment = MyAlertDialogFragment.newInstance(
            R.string..alert_dialog_two_buttons_title);
    newFragment.setCancelable(false);
    newFragment.show(getFragmentManager(), "dialog");
}

这篇关于AlertDialog的setCancelable(假)方法不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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