private void LoadFragment(int id) { switch (id) { case Resource.Id.menu_breakfast: SupportFragmentManager.BeginTransaction().Hide(activeFragment).Show(this.Fragments[0]).Commit(); activeFragment = this.Fragments[0]; break; case Resource.Id.menu_diner: SupportFragmentManager.BeginTransaction().Hide(activeFragment).Show(this.Fragments[1]).Commit(); activeFragment = this.Fragments[1]; break; case Resource.Id.menu_souper: SupportFragmentManager.BeginTransaction().Hide(activeFragment).Show(this.Fragments[2]).Commit(); activeFragment = this.Fragments[2]; break; case Resource.Id.menu_collation: SupportFragmentManager.BeginTransaction().Hide(activeFragment).Show(this.Fragments[3]).Commit(); activeFragment = this.Fragments[3]; break; } }
public static MealFragment NewInstance(string pageTitle, MealViewModel mealViewModel) { MealFragment mealFragment = new MealFragment(); Bundle args = new Bundle(); mealFragment.mealViewModel = mealViewModel; args.PutString(PageTitleArgKey, pageTitle); mealFragment.Arguments = args; return(mealFragment); }
private void LoadFragments() { this.activeFragment = this.Fragments[0] = MealFragment.NewInstance(this.BottomNavigationView.Menu.GetItem(0).TitleFormatted.ToString(), MealViewModel); SupportFragmentManager.BeginTransaction().Add(Resource.Id.content_frame, this.activeFragment).Commit(); for (var i = 1; i < Fragments.Length; i++) { this.Fragments[i] = MealFragment.NewInstance(this.BottomNavigationView.Menu.GetItem(i).TitleFormatted.ToString(), MealViewModel); SupportFragmentManager.BeginTransaction().Add(Resource.Id.content_frame, this.Fragments[i]).Hide(this.Fragments[i]).Commit(); } }