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


            fragments = new List <FragmentBase>();

            fragments.Add(new Page0Patients(this.Parent)
            {
                FID = 0
            });
            fragments.Add(new Page1Doctors(this.Parent)
            {
                FID = 1
            });
            for (int i = 2; i < 4; i++)
            {
                fragments.Add(new FragmentBase(this.Parent)
                {
                    FID = i
                });
            }

            SetContentView(Resource.Layout.pager_layout);



            editToolbar       = FindViewById <Toolbar>(Resource.Id.edit_toolbar);
            editToolbar.Title = "Patients";
            editToolbar.InflateMenu(Resource.Layout.edit_menus);
            editToolbar.MenuItemClick += (sender, e) => {
                Toast.MakeText(this, "Bottom toolbar tapped: " + e.Item.TitleFormatted, ToastLength.Short).Show();
            };



            mPager               = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.pager);
            mPagerAdapter        = new ScreenSlidePagerAdapter(ref fragments, SupportFragmentManager);
            mPager.Adapter       = mPagerAdapter;
            mPager.PageSelected += mPager_PageSelected;
        }
        /// <summary>
        /// Creates a tab provider to be used for the given adapter.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="adapter">The adapter.</param>
        /// <returns>
        /// Must return an ITabProvider instance.
        /// </returns>
        public virtual ITabProvider CreateTabProvider(Context context, Android.Support.V4.View.PagerAdapter adapter)
        {
            ITabProvider tabProvider = adapter as ITabProvider;

            if (tabProvider != null)
            {
                return(tabProvider);
            }
            else
            {
                //if the adapter supports the IIconTabProvider interface, then create
                //an instance of the IconTabProvider, otherwise use the TextTabProvider.
                if (adapter is PagerSlidingTabStrip.IIconTabProvider)
                {
                    return(CreateIconTabProvider(context, adapter));
                }
                else
                {
                    return(CreateTextTabProvider(context, adapter));
                }
            }
        }