AlertDialog的setCancelable(假)方法不工作方法、工作、AlertDialog、setCancelable

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

我已经创建了一个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.

推荐答案

是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");
}
阅读全文

相关推荐

最新文章