https://blog.csdn.net/aiynmimi/article/details/105586933
dialogFragment.showNow()->dialogFragment.showAllowingStateLoss
open fun showAllowingStateLoss(manager: FragmentManager, tag: String?) {
try {
val dismissed = DialogFragment::class.java.getDeclaredField("mDismissed")
dismissed.isAccessible = true
dismissed[this] = false
} catch (e: NoSuchFieldException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
try {
val shown = DialogFragment::class.java.getDeclaredField("mShownByMe")
shown.isAccessible = true
shown[this] = true
} catch (e: NoSuchFieldException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
val ft = manager.beginTransaction()
ft.add(this, tag)
ft.commitAllowingStateLoss()
}
网友评论