【问题标题】:How to avoid multiple display of a dialog if it is called several times at the same time?如果同时调用多次,如何避免多次显示对话框?
【发布时间】:2020-07-03 07:18:33
【问题描述】:

这个检查不起作用

 fun showDialog() {
        if (supportFragmentManager.findFragmentByTag(FailureDialog.TAG) == null) {
            FailureDialog().show(supportFragmentManager, FailureDialog.TAG)
        }
    }

【问题讨论】:

    标签: android android-studio android-fragments kotlin


    【解决方案1】:

    对话框因此异步添加到片段管理器,检查不起作用,在这种情况下值得使用showNow()

    fun showDialog() {
            if (supportFragmentManager.findFragmentByTag(FailureDialog.TAG) == null) {
                FailureDialog().showNow(supportFragmentManager, FailureDialog.TAG)
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2015-08-16
      • 2021-10-16
      • 2020-05-09
      • 2020-01-09
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多