欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

DialogFragment不可取消

程序员文章站 2022-04-24 14:24:42
...
class LoadingDialog : DialogFragment() {
    ...
    
    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {

        val layout = requireActivity().layoutInflater.inflate(R.layout.loading_view, null)
        val showText = layout.findViewById<TextView>(R.id.showMsgLoadingDialog)
        showText.setText(msg)
        val myDialog = requireActivity().run {
            val builder = AlertDialog.Builder(this)
            builder.setView(layout)
            builder.create()
        }
        myDialog.setCancelable(false) //返回键不可取消
        myDialog.setCanceledOnTouchOutside(false) //点击外部不取消
        isCancelable=false  //侧滑,Fragment不可取消
        return myDialog
    }
    ...
    
}
相关标签: 零碎 android