DialogFragment setCancelable property not working

后端 未结 5 2077
闹比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:40

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        AlertDialog.Builder(activity!!).apply {
            isCancelable = false
            setMessage("Your message")
            // your other adjustments
            return this.create()
        }
     }
    

    worked for me.

    The main thing is to use isCancelable = false over setCancellable(false)
    within override fun onCreateDialog().

提交回复
热议问题