Detect back button but don't dismiss dialogfragment

后端 未结 9 1177
时光取名叫无心
时光取名叫无心 2020-11-30 02:00

I have a dialogfragment for a floating dialog which includes a special keyboard that pops up when a user presses inside an EditText field (the normal IME is stopped from bei

9条回答
  •  旧巷少年郎
    2020-11-30 02:45

    Use onDismiss() callback of DialogFragment with a closeActivity flag

    private var closeActivity: Boolean = true    
    
    override fun onDismiss(dialog: DialogInterface?) {
            super.onDismiss(dialog)
    
            if (closeActivity) {
                activity!!.finish()
            }
        }
    

提交回复
热议问题