DialogFragment setCancelable property not working

后端 未结 5 2086
闹比i
闹比i 2020-12-25 09:25

I am working in an android application and am using a DialogFragment to show a dialog and I want to make that DialogFragment not cancelable. I have made the dialog cancelabl

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 09:53

    Use the following Snippet

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

    and if you want to disable the out side touch around dialog use the following line of code

    DialogFragment.getDialog().setCanceledOnTouchOutside(true);
    

提交回复
热议问题