代码
/** * [fragmentClass]是否是活跃Fragment */ public fun <F : Fragment> isActiveFragment(fragmentClass: Class<F>): Boolean { val navHostFragment = this.supportFragmentManager.fragments.first() as NavHostFragment navHostFragment.childFragmentManager.fragments.forEach { if (fragmentClass.isAssignableFrom(it.javaClass)) { return true } } return false }
本文来自博客园,作者:观心静 ,转载请注明原文链接:https://www.cnblogs.com/guanxinjing/p/14921885.html
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。