protected override void OnCreateActivity(Bundle state) { base.OnCreateActivity(state); SetContentView(Resource.Layout.ProjectListActivityLayout); // Check if fragment is still in Fragment manager. var fragment = FragmentManager.FindFragmentByTag(fragmentTag); if (fragment == null) { var extras = Intent.Extras; if (extras == null) { Finish(); } var extraGuids = extras.GetStringArrayList(ExtraTimeEntriesIds); fragment = ProjectListFragment.NewInstance(extraGuids); FragmentManager.BeginTransaction() .Add(Resource.Id.ProjectListActivityLayout, fragment, fragmentTag) .Commit(); } else { FragmentManager.BeginTransaction() .Attach(fragment) .Commit(); } }
public static void Start(FragmentManager mgr, string email, RegisterUserViewModel vm) { // Find old fragment to replace var frag = mgr.FindFragmentByTag("google_auth"); if (frag != null) { var authFrag = frag as GoogleAuthFragment; if (authFrag != null && authFrag.IsAuthenticating) { // Authentication going on still, do nothing. return; } } viewModel = vm; var tx = mgr.BeginTransaction(); if (frag != null) { tx.Remove(frag); } tx.Add(new GoogleAuthFragment(email), "google_auth"); tx.Commit(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ViewModelLocator.Init(new IModule[] { new DIModulesDROID() }); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); SupportV4.App.FragmentManager fragMgr = this.SupportFragmentManager; var xact = fragMgr.BeginTransaction(); if (null == fragMgr.FindFragmentByTag(_FRAG1_TAG)) { var fragment = new MyFragment(); xact.Add(Android.Resource.Id.Content, fragment, _FRAG1_TAG); } xact.CommitAllowingStateLoss(); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.tasksToolbar); //Toolbar will now take on default Action Bar characteristics //SetActionBar (toolbar); SetSupportActionBar(toolbar); //SetUpMap(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_map); mFragmentManager = SupportFragmentManager; mFragmentManager.AddOnBackStackChangedListener(this); mFragmentBreadCrumbs = FindViewById <FragmentBreadCrumbs>(Resource.Id.breadcrumbs); mFragmentBreadCrumbs.SetActivity(this); mMapFragment = (MapFragment)mFragmentManager.FindFragmentByTag("map"); if (mMapFragment == null) { mMapFragment = new MapFragment(); mMapFragment.Arguments = IntentToFragmentArguments(Intent); mFragmentManager.BeginTransaction() .Add(Resource.Id.fragment_container_map, mMapFragment, "map") .Commit(); } FindViewById <ImageButton>(Resource.Id.close_button).Click += (sender, e) => { ClearBackStack(SupportFragmentManager); }; UpdateBreadCrumb(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_map); mFragmentManager = SupportFragmentManager; mFragmentManager.AddOnBackStackChangedListener(this); mFragmentBreadCrumbs = FindViewById<FragmentBreadCrumbs>(Resource.Id.breadcrumbs); mFragmentBreadCrumbs.SetActivity(this); mMapFragment = (MapFragment)mFragmentManager.FindFragmentByTag("map"); if (mMapFragment == null) { mMapFragment = new MapFragment(); mMapFragment.Arguments = IntentToFragmentArguments(Intent); mFragmentManager.BeginTransaction() .Add(Resource.Id.fragment_container_map, mMapFragment, "map") .Commit(); } FindViewById<ImageButton>(Resource.Id.close_button).Click += (sender, e) => { ClearBackStack(SupportFragmentManager); }; UpdateBreadCrumb(); }
/** * Build and add "sessions" tab. */ private void SetupSessionsTab() { // TODO: this is very inefficient and messy, clean it up FrameLayout fragmentContainer = new FrameLayout(this); fragmentContainer.Id = Resource.Id.fragment_sessions; fragmentContainer.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent); FindViewById <ViewGroup> (Android.Resource.Id.TabContent).AddView(fragmentContainer); FragmentManager fm = SupportFragmentManager; mSessionsFragment = (SessionsFragment)fm.FindFragmentByTag("sessions"); if (mSessionsFragment == null) { mSessionsFragment = new SessionsFragment(); mSessionsFragment.Arguments = GetSessionsFragmentArguments(); fm.BeginTransaction() .Add(Resource.Id.fragment_sessions, mSessionsFragment, "sessions") .Commit(); } else { mSessionsFragment.ReloadFromArguments(GetSessionsFragmentArguments()); } // Sessions content comes from reused activity mTabHost.AddTab(mTabHost.NewTabSpec(TAG_SESSIONS) .SetIndicator(BuildIndicator(Resource.String.starred_sessions)) .SetContent(Resource.Id.fragment_sessions)); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); Android.Support.V4.App.FragmentManager fm = ChildFragmentManager; SupportMapFragment mapFragment = (SupportMapFragment)fm.FindFragmentByTag("mapFragment"); if (mapFragment == null) { mapFragment = new SupportMapFragment(); Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction(); ft.Add(Resource.Id.notam_mapDialog_mapContainer, mapFragment, "mapFragment"); ft.Commit(); fm.ExecutePendingTransactions(); } mapFragment.GetMapAsync(this); _buttonContainerBottom.AddView(_dismissButton); }
/// <summary> /// Replaces the fragment. /// </summary> /// <param name="fragment">Fragment.</param> public void replaceFragment(Android.Support.V4.App.Fragment fragment) { String fragmentName = fragment.Class.Name; System.Diagnostics.Debug.WriteLine(string.Format("========== Fragment Name ======== {0}", fragmentName)); Android.Support.V4.App.FragmentManager fragmentManager = this.SupportFragmentManager; bool popSuccess = fragmentManager.PopBackStackImmediate(fragmentName, 0); if (!popSuccess && fragmentManager.FindFragmentByTag(fragmentName) == null) { //Replace Fragment Android.Support.V4.App.FragmentTransaction ft = fragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragmentFrameLayout, fragment, fragmentName); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.AddToBackStack(fragmentName); ft.Commit(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); btn = FindViewById <Button>(Resource.Id.btnClick); fragmentManager = SupportFragmentManager; btn.Click += (sender, args) => { if (fragmentManager.FindFragmentByTag(ContextMenuDialogFragment.TAG) == null) { mMenuDialogFragment.Show(fragmentManager, ContextMenuDialogFragment.TAG); } }; initMenuFragment(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Intent intent = new Intent(); intent.SetData(ScheduleContract.Sessions.BuildSessionsAtDirUri(Java.Lang.JavaSystem.CurrentTimeMillis())); SetContentView(Resource.Layout.activity_now_playing); FragmentManager fm = SupportFragmentManager; mSessionsFragment = (SessionsFragment)fm.FindFragmentByTag("sessions"); if (mSessionsFragment == null) { mSessionsFragment = new SessionsFragment(); mSessionsFragment.Arguments = IntentToFragmentArguments(intent); fm.BeginTransaction() .Add(Resource.Id.fragment_container_sessions, mSessionsFragment, "sessions") .Commit(); } }
public static void Start (FragmentManager mgr, string email) { // Find old fragment to replace var frag = mgr.FindFragmentByTag ("google_auth"); if (frag != null) { var authFrag = frag as GoogleAuthFragment; if (authFrag != null && authFrag.IsAuthenticating) { // Authentication going on still, do nothing. return; } } var tx = mgr.BeginTransaction (); if (frag != null) { tx.Remove (frag); } tx.Add (new GoogleAuthFragment (email), "google_auth"); tx.Commit (); }