Advance navigation sample: Reset to startDestination
I need case where when tab selected, it always go to navController.startDestination, any ideas how to do this?
Interested too, any solution ?
I trick with this before " if (firstFragmentTag != newlySelectedItemTag) {"
// When item in bottom nav changed, need to reset the graph of the tab we are leaving
val previousFragment = fragmentManager.findFragmentByTag(selectedItemTag) as NavHostFragment
previousFragment.navController.let { it.popBackStack(it.graph.startDestination, true) }
It works but with shared elements it is not working .
I am also interested in this. If any one has any insight.
I add onItemClickedListener and everytime user navigate away, before returning the boolean, the bottom nav clear the stack of the previous selected tab.
I add onItemClickedListener and everytime user navigate away, before returning the boolean, the bottom nav clear the stack of the previous selected tab.
Some code please ? :)
This is how I work around this ExtendedBottomNavigationView.kt Sorry I can't be more specific since I already quit my previous job and lost access to their repository
on a side note: What the... I can't embed gist link in Github issue comment?
I did it but checking for the start id of each the bottom nav graph in activity onBackPressed, then do following: super.onBackPressed() currentLiveNavController?.value?.popBackStack(R.id.fragment_home, false)
The problem with this popToBackStack is that parent previous fragment is recreated (the popped fragment)
😕