I have An activity with a navGraph and a bottom Navigation bar with 2 menu items. My problem is that My Bottom Navigation Bar appears everywhere, detailFragment, aboutFragment, signInFragment and so on.
val navController = this.findNavController(R.id.myNavHostFragment)
val appBarConfiguration = AppBarConfiguration.Builder(
R.id.contactsFragment,
R.id.profileFragment
).build()
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration)
val navView: BottomNavigationView = findViewById(R.id.nav_view)
NavigationUI.setupWithNavController(navView, navController)
How do i Limit it to just show on the 2 fragments on my menu Item?
This is how I solved It
navController.addOnDestinationChangedListener{ _, nd: NavDestination, _->
if(nd.id == R.id.contactsFragment || nd.id == R.id.profileFragment){
navView.visibility = View.VISIBLE
}else{
navView.visibility = View.GONE
}