How do I reopen a fragment, that i previously navigated to with the NavHostFragment?
Navigation Drawer:
Home => Animals-Fragment
Fragments:
Animals-Fragment => Bunnies-Fragment => Temporarily change Bunny color to blue from red
Navigation Drawer:
Bunnies-Fragment => Home
Now I want, that when I click on Animals, it shows the Bunnies-Fragment that was altered. This means, I want the already loaded instance of that Fragment. How do I do that?
I'm using following code to swap between Fragments:
NavHostFragment.findNavController(p)
.navigate(R.id.action_navigation_animals_to_bunniesFragment, bundle);
my HomeActivity has this in its onCreate():
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_animals)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
question from:
https://stackoverflow.com/questions/65946192/navhostfragment-reopen-changed-fragment-with-navigation-drawer 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…