I would develop an android app with Single Activity and Two Fragments (LoginFragment and HomeFragment) with Navigation Drawer using Navigation Graph.
When I had add a Navigationdrawer
in my activity it is visible in LoginFragment
but I want to display hamburger icon only in HomeFragment
not LoginFragment
.
How to add a navigation drawer in activity without add it to LoginFragment
I had tried to hide a toolbar
val navController=this.findNavController(R.id.nav_host_fragment)
navController.addOnDestinationChangedListener{ nc: NavController, nd: NavDestination, _->
if(nd.id==nc.graph.startDestination){
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
binding.toolBar.visibility = View.GONE
}else{
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
NavigationUI.setupActionBarWithNavController(this,navController,drawerLayout)
binding.toolBar.visibility = View.VISIBLE
}
I want to display hamburger icon only in HomeFragment
not LoginFragment