美文网首页
DialogFragment崩溃 Can not perform

DialogFragment崩溃 Can not perform

作者: 周大侠侠侠侠侠侠侠侠侠侠侠侠侠 | 来源:发表于2019-02-19 18:21 被阅读0次
        //重写DialogFragment的show方法
        //可以查看showAllowingStateLoss不过被hide
        //通过反射拿到这两个变量进行设置
       try {
            val mDismissed = DialogFragment::class.java.getDeclaredField("mDismissed")
            mDismissed.isAccessible = true
            mDismissed.set(this, false)
            val mShownByMe = DialogFragment::class.java.getDeclaredField("mShownByMe")
            mShownByMe.isAccessible = true
            mShownByMe.set(this, true)
            manager.beginTransaction()
                    .add(this, tag)
                    .commitAllowingStateLoss()
            }
        } catch (e: Throwable) {
            LogUtils.eTag(TAG, e.toString())
        }

相关文章

网友评论

      本文标题:DialogFragment崩溃 Can not perform

      本文链接:https://www.haomeiwen.com/subject/iiifyqtx.html