public void OnTabChanged(string tabId) { TabInfo newTab = this.mapTabInfo[tabId]; newTab.args.PutString("ProcessID", ProcessID); //if (mLastTab != newTab) //{ Android.Support.V4.App.FragmentTransaction ft = this.SupportFragmentManager.BeginTransaction(); if (mLastTab != null) { if (mLastTab.fragment != null) { ft.Detach(mLastTab.fragment); } } if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = Android.Support.V4.App.Fragment.Instantiate(this, Java.Lang.Class.FromType(newTab.clss).Name , newTab.args); ft.Add(Resource.Id.realtabcontent, newTab.fragment, newTab.tag); } else { ft.Attach(newTab.fragment); } } mLastTab = newTab; ft.Commit(); this.SupportFragmentManager.ExecutePendingTransactions(); //} }
private void SelectLibrary(Library library) { if (IsFinishing) { return; } App.STATE.CurrentLibrary = library; string tag = Enum.GetName(typeof(Library), library); FragmentTransaction transaction = SupportFragmentManager.BeginTransaction(); transaction.SetTransition((int)FragmentTransit.FragmentFade); Fragment fragment = SupportFragmentManager.FindFragmentByTag(tag); if (App.STATE.CanTranslate()) { if (fragment == null) { if (App.STATE.CurrentLibrary == Library.DailyText) { string date = App.FUNCTIONS.FormatDateTime(DateTime.Now); fragment = new ArticleFragment(NavStruct.Parse(date), library); fragment.RetainInstance = true; } //else if (App.STATE.CurrentLibrary == Library.Insight) //{ // fragment = new InsightLibraryFragment(); // fragment.RetainInstance = true; //} else { fragment = new LibraryFragment(); fragment.RetainInstance = true; } if (SelectedFragment != null) { transaction.Detach(SelectedFragment); } transaction.Add(Resource.Id.content_frame, fragment, tag); transaction.Commit(); } else { transaction.Detach(SelectedFragment); transaction.Attach(fragment); transaction.Commit(); } SelectedFragment = fragment; int index = App.STATE.Libraries.IndexOf(library); list.SetItemChecked(index, true); list.SetSelection(index); drawer.CloseDrawer(list); } else { // Temporary HACK SupportFragmentManager.PopBackStack(null, (int)PopBackStackFlags.Inclusive); SelectedFragment = null; transaction.Replace(Resource.Id.content_frame, new Fragment()).Commit(); RunOnUiThread(() => { list.Adapter = null; }); } Console.WriteLine("Current LibraryMode is " + App.STATE.CurrentLibrary.ToString()); }