I'm trying to use the new Jetpack navigation component. I use a BottomNavigationView with the navController : NavigationUI.setupWithNavController(bottomNavigation, navController)
But when I'm switching fragments, each fragment will be reloaded! is there any way to stop fragment reloading/refreshment?
I had problems with reloading also. This helped me.
override fun onCreate(savedInstanceState: Bundle?) {
...
val navController = Navigation.findNavController(this, R.id.mainFragment)
bottomNavigation.setOnNavigationItemSelectedListener {
if (it.itemId != bottomNavigation.selectedItemId)
NavigationUI.onNavDestinationSelected(it, navController)
true
}
This this stopped reloading on multiple clicks on bottom navigation item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With