public bool OnNavigationItemSelected(IMenuItem menuItem) { if (menuItem.IsChecked) { mDrawerLayout.CloseDrawer(mNavView); return(false); } Fragment fragment = null; var titleId = -1; switch (menuItem.ItemId) { case (Resource.Id.nav_system_overview): fragment = new NodeFragment(); titleId = Resource.String.system_overview; break; case (Resource.Id.nav_garage_doors): fragment = new GarageDoorFragment(); titleId = Resource.String.doors; break; case (Resource.Id.nav_garage_webcam): fragment = new WebViewFragment(Urls.GarageWebcam); titleId = Resource.String.webcam; break; case (Resource.Id.nav_guest_room_sensors): fragment = new SensorFragment(); titleId = Resource.String.sensors; break; case (Resource.Id.nav_guest_room_phat_sensors): fragment = new EnviroFragment(); titleId = Resource.String.phat_sensors; break; case (Resource.Id.nav_robot_webcam): fragment = new WebViewFragment(Urls.RobotWebcam); titleId = Resource.String.webcam; break; } FragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .AddToBackStack(null) .Commit(); mNavView.SetCheckedItem(menuItem.ItemId); mDrawerLayout.CloseDrawer(mNavView); SetTitle(titleId); InvalidateOptionsMenu(); // refresh options menu return(false); }
private void ShowSystemOverview() { // update the main content by replacing fragments Fragment fragment = new NodeFragment(); FragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); // update selected item and title, then close the drawer mNavView.SetCheckedItem(Resource.Id.nav_system_overview); SetTitle(Resource.String.system_overview); mDrawerLayout.CloseDrawer(mNavView); }