android开发DialogFragment禁止按back键消失的解决方法


override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val ctx = context ?: return super.onCreateDialog(savedInstanceState)
var builder: AlertDialog.Builder = AlertDialog.Builder(ctx, R.style.CenterDialogStyle)
builder.setView(view)
val dialog = builder.create()
dialog.setCanceledOnTouchOutside(false)
dialog.setCancelable(false) //无效
isCancelable = false  //有效,设置这个才有效,上面的那个无效,坑死了,网上一堆无用的监听key事件,我去。。。
return dialog
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM