How to dismiss a DialogFragment when pressing outside the dialog?

前端 未结 8 563
盖世英雄少女心
盖世英雄少女心 2020-12-04 17:05

I am using a DialogFragment, and while I have successfully set an image to close (i.e. dismiss) the dialog when pressed, I am having a hard time finding the way

相关标签:
8条回答
  • 2020-12-04 18:08
    DialogFragment.getDialog().setCanceledOnTouchOutside(false);
    

    It was mistyping. I had the same problem. This works fine for Java and Mono for android Mono will be:

    this.getDialog().SetCanceledOnTouchOutside(false);
    
    0 讨论(0)
  • 2020-12-04 18:08

    If you want to execute some logic when clicking outside of a DialogFragment, just override the onCancel method.

    override fun onCancel(dialog: DialogInterface) {
        super.onCancel(dialog)
        // Do your work here
    }
    
    0 讨论(0)
提交回复
热议问题