I am currently developing an android application (https://github.com/Team4388/ScoutingApp2025/tree/stackoverflow-fragment-nav-weirdness) and I have recently swapped everything over to use sub-fragments and actions instead of enabling and disabling visibility to emulate sub pages.
This has introduced some bugs though.
- When switching between fragments using the nav: going to a subfragment, switching nav views, and then back, the subfragment of the page is still there, not the root fragment. And also the navbar shows the incorrect option selected.
- Sometimes, after preforming the steps from before, and then switching to a sub fragment, it will cause an error “<uuid> not associated with a fragment manager.”, or sometimes it will give an error that the action cannot be accessed from the current fragment (I’m not using global actions)
From my guess, this is because the subfragment does not return to the root fragment which causes errors.
Here is my current navigation configuration:
appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_scouting,
R.id.navigation_data,
R.id.navigation_transfer,
R.id.navigation_settings)
.build();
navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
Everything I found hasn’t worked, or has resulted in more things not working properly.
Astatine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.