BottomSheetDialogFragment - listen to dismissed by user event

后端 未结 6 1912
野性不改
野性不改 2021-01-01 08:56

How can I listen to a FINAL dismissal of a BottomSheetDialogFragment? I want to save user changes on the final dismissal only...

I tried following:

6条回答
  •  隐瞒了意图╮
    2021-01-01 09:58

    i achieved this using this simple trick

    val bottomSheetDialog = FeedbackFormsFragment.createInstance()
    bottomSheetDialog.show((activity as FragmentActivity).supportFragmentManager, BOTTOM_SHEET)
    
    
    // add some delay to allow the bottom sheet to be visible first so that the dialog is not null
    
                    Handler().postDelayed({
                        bottomSheetDialog.dialog?.setOnDismissListener {
    
                           // add code here
                        }
                    }, 1000)
    

提交回复
热议问题