Hi have a navigation component with 4 destination, and I add that destination in an option menu.
It works perfectly, but now I need to move from a selected fragment to another one, but I didn't found any solution, because I can open my selected fragment, but I can't reopen the first one.
This is the configuration of nav controller in MainActivity:
val navView: NavigationView = binding.navView
navController = findNavController(R.id.nav_host_fragment)
appBarConfiguration = AppBarConfiguration(
setOf(
R.id.nav_home,
R.id.nav_two,
R.id.nav_three,
R.id.nav_four
), drawerLayout
)
navController?.let {
setupActionBarWithNavController(it, appBarConfiguration)
navView.setupWithNavController(it)
}
This is the (wrong) call in second fragment to go programmatically to go to forth fragment:
requireActivity().findNavController(R.id.nav_host_fragment).navigate(R.id.nav_four)
Like I say, I go correctly to fourth fragment, but navigation not work correctly, because after that it's impossible to select home fragment selection in side menu.
Any solutions?