public override bool OnOptionsItemSelected(IMenuItem item) { MyFragment fragement = FragmentManager.FindFragmentByTag <MyFragment>(MyFragment.PAGE_CONTENT); MyUtil.HideSoftKeyboard(this); switch (item.ItemId) { case Resource.Id.nav_home: MyUtil.GoPage(fragement, PAGE.HOME); return(true); case Resource.Id.nav_register: MyUtil.GoPage(fragement, PAGE.REGI); return(true); case Resource.Id.nav_list: MyUtil.GoPage(fragement, PAGE.LIST); return(true); default: if (drawerLayout.IsDrawerOpen(navigationView)) { drawerLayout.CloseDrawers(); } else { drawerLayout.OpenDrawer(navigationView); } return(true); } }
public static void GoPage(MyFragment fragment, PAGE page) { MyAppCompatActivity.CURRENT_PAGE = page; FragmentTransaction ft = fragment.FragmentManager.BeginTransaction(); if (page == PAGE.HOME) { ft.Replace(Resource.Id.page_placeholder, new PageMainFragment(), MyFragment.PAGE_CONTENT); } else if (page == PAGE.REGI) { ft.Replace(Resource.Id.page_placeholder, new PageRegisterFragment(), MyFragment.PAGE_CONTENT); } else if (page == PAGE.LIST) { ft.Replace(Resource.Id.page_placeholder, new PageListFragment(), MyFragment.PAGE_CONTENT); } ft.Commit(); }
public static void GoList(MyFragment fragment) { GoPage(fragment, PAGE.LIST); }
public static void GoRegister(MyFragment fragment) { GoPage(fragment, PAGE.REGI); }
public static void GoHome(MyFragment fragment) { GoPage(fragment, PAGE.HOME); }