Issue
I copied the NavigationExtensions.kt extension file from the NavigationAdvancedSample and I get this exception:
Solution
UPDATE: make sure your menu item ids are the same as your navigation resource files ids
also: if you're having a problem with ItemReselectedListener Add null safety checks, your listener should be something like this:
setOnNavigationItemReselectedListener { item ->
val newlySelectedItemTag = graphIdToTagMap[item.itemId]
val selectedFragment = fragmentManager.findFragmentByTag(newlySelectedItemTag)
as NavHostFragment?
val navController = selectedFragment?.navController
// Pop the back stack to the start destination of the current navController graph
navController?.popBackStack(
navController.graph.startDestination, false
)
}
Answered By - tahaak97
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.