fragment stuck cannot move to another fragment in Android Navigation

Muhammad Yaasiin Hidayatulloh
2 min readApr 22, 2022
Photo by Tony Pepe on Unsplash

Hello folks, first time meeting with me. The biggest challenge in android development when some components are having problems after deprecated or updating to latest version. Sometimes what makes some novice android developers confused about this problem, what should I do. Do you have to replace it with another component, or do you have to manually create your own function to replace the component itself.

Photo by Jared Murray on Unsplash

In here I want to explain how to fix fragment stuck cannot move to another fragment in Android Navigation. One of the things that inspired me to write this article, after a few months of confusion about creating a personal project. Why can’t this section move from frame to frame, or did I mess up the code I wrote in that section(one of the most important components in building a more complex application). So, don’t let me be nicknamed TMT or Talk a lot. Let’s have a look at the sample code I’m about to explain.

code when a fragment can’t move to another fragment

then I tried to find a solution, then like this

the code when the fragment is successfully repaired moves to another fragment

But, look the crossed out and highlighted writing there, it feels a bit sensitive if you find it. Posts describing deprecated component library functions. Therefore, I will try to explain briefly how to solve it, by creating a simple utils function to make the function disappear underlined scribbles and the code is simpler than that function.

code NavSelectedItemListener utils function

Then to call it in MainActivity class like this

MainActivity when calling utils function NavSelectedItemListener

That’s all I want to say. Finally, if you have any comments or suggestions, please comment below. Happy if you provide suggestions and additions in this article, hope it helps. Thanks

--

--