コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.BackActivity);

            // Load the back fragment
            Fragment            backFrag = FragmentManager.FindFragmentById(Resource.Id.backFragment);
            FragmentTransaction ft       = FragmentManager.BeginTransaction();

            // Is there a fragment in the frame layout?
            if (backFrag != null)
            {
                ft.Remove(backFrag);
            }
            backFrag = new BackFragment(false);
            ft.Add(Resource.Id.backFragment, backFrag);
            ft.Commit();
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.FrontActivity);

            // see if a dual-pane layout is loaded
            bool isDualPane = (FindViewById(Resource.Id.backFragment) != null);

            // Load the front fragment
            Fragment            frontFrag = FragmentManager.FindFragmentById(Resource.Id.frontFragment);
            FragmentTransaction ft        = FragmentManager.BeginTransaction();

            // Is there a fragment in the frame layout?
            if (frontFrag != null)
            {
                ft.Remove(frontFrag);
            }
            frontFrag = new FrontFragment(isDualPane);
            ft.Add(Resource.Id.frontFragment, frontFrag);
            ft.Commit();

            // Load the back fragment, if a dual-pane layout is loaded
            if (isDualPane)
            {
                var backFrag = FragmentManager.FindFragmentById(Resource.Id.backFragment);
                ft = FragmentManager.BeginTransaction();
                // Is there a fragment in the frame layout?
                if (backFrag != null)
                {
                    ft.Remove(backFrag);
                }
                backFrag = new BackFragment(isDualPane);
                ft.Add(Resource.Id.backFragment, backFrag);
                ft.Commit();
            }
        }