Android Fragment UI not updated after popBackStack()

Have you ever experience your fragment’s UI not updating after exit from another fragment?

I spent hours to find out that the reason of this weirdness is that the fragment state after supportFragmentManager.popBackStack() is causing this issue


So, the solution is to use

supportFragmentManager.popBackStackImmediate("theFragment", 0)

instead, where the “theFragment” is the fragment name used when you add the fragment to back stack:

val transaction = supportFragmentManager.beginTransaction()
transaction.replace(, fragment)

Using supportFragmentManager.popBackStackImmediate(“theFragment”, 0) can make sure your fragment is in the correct state for updating the UI elements.

That’s it.

Happy coding.

Let me know if you find better solution or approach in the comment section below. ;)

Find me at Twitter @rick3817



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

Hi this is Rick from Hong Kong. I am a native iOS and Android mobile developer and also a tech enthusiast. Find me on Twitter