Fragment's onResume() not called when popped from backstack

前端 未结 7 2014
梦谈多话
梦谈多话 2021-02-04 01:17

Hi I am developing android application in which I am using I am using single Activity and 3 fragments. So consider I have 3 fragments A B C. When I switch from A to

7条回答
  •  囚心锁ツ
    2021-02-04 02:02

    I use this way, add this block code in your fragment

    requireActivity().supportFragmentManager.addOnBackStackChangedListener {
                val fm = requireActivity().supportFragmentManager
                fm?.let {
                    if (it.backStackEntryCount == YOUR_FRAGMENT_BACK_STACK_INDEX) {
                        // your fragment visible
                    }
                }
            }
    

提交回复
热议问题