I just started using Android NavigationUI to implement Fragment Navigation through a drawer menu. While it does feel a bit like magic, I have one main issue with it. That is, I have a logout
item in the menu that should not Navigate to any Fragment, but rather to an "action". While I found similar questions here such as this one, I haven't found a clear answer to my question yet. The following is the function I'm currently using to setup the navigation:
private fun setupNav() {
val binding: ActivityMainMenuBinding = DataBindingUtil.setContentView(this,
R.layout.activity_main_menu)
drawerLayout = binding.drawerLayout
navController = Navigation.findNavController(this, R.id.content_frame)
appBarConfiguration = AppBarConfiguration(navController.graph, drawerLayout)
// Set up ActionBar
setSupportActionBar(binding.toolbar)
setupActionBarWithNavController(navController, appBarConfiguration)
binding.navView.setupWithNavController(navController)
}
If you have any suggestions on how I could approach this, it would be truly appreciated if you could share them.