protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.fragment_stack);

            // Watch for button clicks.
            Button button = (Button)FindViewById(R.Id.new_fragment);

            button.Click += (s, x) => AddFragmentToStack();

            button        = (Button)FindViewById(R.Id.home);
            button.Click += (s, x) =>
            {
                // If there is a back stack, pop it all.
                FragmentManager fm = GetSupportFragmentManager();
                if (fm.GetBackStackEntryCount() > 0)
                {
                    fm.PopBackStack(fm.GetBackStackEntryAt(0).GetId(),
                                    Android.Support.V4.App.FragmentManager.POP_BACK_STACK_INCLUSIVE);
                }
            };

            if (savedInstanceState == null)
            {
                // Do first time initialization -- Add initial fragment.
                Fragment            newFragment = CountingFragment.NewInstance(mStackLevel);
                FragmentTransaction ft          = GetSupportFragmentManager().BeginTransaction();
                ft.Add(R.Id.simple_fragment, newFragment).Commit();
            }
            else
            {
                mStackLevel = savedInstanceState.GetInt("level");
            }
        }
Esempio n. 2
0
        void AddFragmentToStack()
        {
            _stackLevel++;

            Fragment newFragment = CountingFragment.NewInstance(this, _stackLevel);

            FragmentManager.BeginTransaction().Replace(Resource.Id.simple_fragment, newFragment)
            .SetTransition(FragmentTransit.FragmentOpen)
            .AddToBackStack(null)
            .Commit();
        }
        void AddFragmentToStack()
        {
            mStackLevel++;

            // Instantiate a new fragment.
            Fragment newFragment = CountingFragment.NewInstance(mStackLevel);

            // Add the fragment to the activity, pushing this transaction
            // on to the back stack.
            FragmentTransaction ft = GetSupportFragmentManager().BeginTransaction();

            ft.Replace(R.Id.simple_fragment, newFragment);
            ft.SetTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            ft.AddToBackStack(null);
            ft.Commit();
        }
        void AddFragmentToStack()
        {
            mStackLevel++;

            // Instantiate a new fragment.
            Fragment newFragment = CountingFragment.NewInstance(mStackLevel);

            // Add the fragment to the activity, pushing this transaction
            // on to the back stack.
            FragmentTransaction ft = GetSupportFragmentManager().BeginTransaction();

            ft.SetCustomAnimations(R.Anims.fragment_slide_left_enter,
                                   R.Anims.fragment_slide_left_exit,
                                   R.Anims.fragment_slide_right_enter,
                                   R.Anims.fragment_slide_right_exit);
            ft.Replace(R.Ids.simple_fragment, newFragment);
            ft.AddToBackStack(null);
            ft.Commit();
        }
Esempio n. 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.umeng_example_analytics_fragment_stack);

            Button button = FindViewById <Button>(Resource.Id.new_fragment);

            button.Click += (e, s) =>
            {
                AddFragmentToStack();
            };

            if (savedInstanceState == null)
            {
                Fragment newFragment = CountingFragment.NewInstance(this, _stackLevel);
                FragmentManager.BeginTransaction().Add(Resource.Id.simple_fragment, newFragment).Commit();
            }
            else
            {
                _stackLevel = savedInstanceState.GetInt("level");
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layouts.fragment_stack);

            // Watch for button clicks.
            Button button = (Button)FindViewById(R.Ids.new_fragment);

            button.Click += (x, y) => AddFragmentToStack();

            if (savedInstanceState == null)
            {
                // Do first time initialization -- Add initial fragment.
                Fragment            newFragment = CountingFragment.NewInstance(mStackLevel);
                FragmentTransaction ft          = GetSupportFragmentManager().BeginTransaction();
                ft.Add(R.Ids.simple_fragment, newFragment).Commit();
            }
            else
            {
                mStackLevel = savedInstanceState.GetInt("level");
            }
        }