Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.MainLayout);
            Android.Support.V4.App.FragmentManager fm       = SupportFragmentManager;
            Android.Support.V4.App.Fragment        fragment = fm.FindFragmentById(Resource.Id.fragmentContainer);

            if (fragment == null)
            {
                fragment = new NewsListFragment();
                fm.BeginTransaction().Add(Resource.Id.fragmentContainer, fragment).Commit();
            }
        }
Exemplo n.º 2
0
        private void ListItemClicked(int position)
        {
            //this way we don't load twice, but you might want to modify this a bit.
            if (position == _oldPosition)
            {
                return;
            }

            _oldPosition = position;

            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                fragment = CalendarFragment.NewInstance();
                fragment.OnAttach(ApplicationContext);
                break;

            case 1:
                fragment = new NewsListFragment();
                fragment.OnAttach(ApplicationContext);
                break;

            case 2:
                fragment = new MemberListFragment();
                fragment.OnAttach(ApplicationContext);
                break;
            }

            if (fragment != null)
            {
                var layout = FindViewById <RelativeLayout>(Resource.Id.content_frame_wrapper);
                layout.SetPadding(_currentPadding[0], _currentPadding[1], _currentPadding[2], _currentPadding[3]);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment).AddToBackStack("tag")
                .Commit();
            }
        }