Inheritance: FragmentPagerAdapter
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            
            SetContentView(Resource.Layout.Front);
            pagerAdapter = new FrontPagerAdapter(SupportFragmentManager);
            var pager = FindViewById<ViewPager>(Resource.Id.MainPager);
            var tabLayout = FindViewById<TabLayout>(Resource.Id.Tabs);
            tabLayout.SetupWithViewPager(pager);
            
            pager.OffscreenPageLimit = 3;
            pager.Adapter = pagerAdapter;
            pager.PageSelected += Pager_PageSelected;

            SetTabContent(tabLayout);
            SetSupportActionBar(MainToolbar);
            
            tabLayout.TabSelected += TabLayout_TabSelected;
            tabLayout.TabUnselected += TabLayout_TabUnselected;

            //Launch setup
            int currentIndex = pager.CurrentItem;
            var selectedTab = tabLayout.GetTabAt(currentIndex);
            var imageView = selectedTab.CustomView as ImageView;
            imageView.SetColorFilter(new global::Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.TabSelected)));
            var title = pagerAdapter.GetTitle(currentIndex);
            SupportActionBar.Title = title;
            AnalyticsHelper.SendView(title);            
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

            SetContentView(Resource.Layout.Front);

            //Utils.SetPaddingForStatusBar(this, MainToolbar);

            pagerAdapter = new FrontPagerAdapter(SupportFragmentManager);
            var pager     = FindViewById <ViewPager>(Resource.Id.MainPager);
            var tabLayout = FindViewById <TabLayout>(Resource.Id.Tabs);

            tabLayout.SetupWithViewPager(pager);

            pager.OffscreenPageLimit = 3;
            pager.Adapter            = pagerAdapter;
            pager.PageSelected      += Pager_PageSelected;

            SetTabContent(tabLayout);
            SetSupportActionBar(MainToolbar);

            tabLayout.TabSelected   += TabLayout_TabSelected;
            tabLayout.TabUnselected += TabLayout_TabUnselected;

            //Launch setup
            int currentIndex = pager.CurrentItem;
            var selectedTab  = tabLayout.GetTabAt(currentIndex);
            var imageView    = selectedTab.CustomView as ImageView;

            imageView.SetColorFilter(new global::Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.TabSelected)));
            var title = pagerAdapter.GetTitle(currentIndex);

            SupportActionBar.Title = title;
            AnalyticsHelper.SendView(title);
        }