protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.navigation_activity); AndroidX.AppCompat.Widget.Toolbar toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); NavHostFragment host = SupportFragmentManager.FindFragmentById(Resource.Id.my_nav_host_fragment) as NavHostFragment; NavController navController = host.NavController; int[] topLevelDestinationIds = new int[] { Resource.Id.home_dest }; appBarConfiguration = new AppBarConfiguration.Builder(topLevelDestinationIds).SetDrawerLayout(FindViewById <DrawerLayout>(Resource.Id.drawer_layout)).Build(); SetupActionBar(navController, appBarConfiguration); SetupNavigationMenu(navController); SetupBottomNavMenu(navController); navController.AddOnDestinationChangedListener(this); }
private void SetupActionBar(NavController navController, AppBarConfiguration appBarConfiguration) { NavigationUI.SetupActionBarWithNavController(this, navController, appBarConfiguration); }