示例#1
0
        private void SetUpViewPager()
        {
            try
            {
                ActivitiesFragment = new UserActivitiesFragment();
                AlbumsFragment     = new UserAlbumsFragment();
                LikedFragment      = new UserLikedFragment();
                PlaylistFragment   = new UserPlaylistFragment();
                SongsFragment      = new UserSongsFragment();
                StationsFragment   = new UserStationsFragment();
                StoreFragment      = new UserStoreFragment();

                Bundle bundle = new Bundle();
                bundle.PutString("UserId", UserDetails.UserId.ToString());

                ActivitiesFragment.Arguments = bundle;
                AlbumsFragment.Arguments     = bundle;
                LikedFragment.Arguments      = bundle;
                PlaylistFragment.Arguments   = bundle;
                SongsFragment.Arguments      = bundle;
                StationsFragment.Arguments   = bundle;
                StoreFragment.Arguments      = bundle;

                MainTabAdapter adapter = new MainTabAdapter(Activity.SupportFragmentManager);
                adapter.AddFragment(ActivitiesFragment, GetText(Resource.String.Lbl_Activities_Title));
                adapter.AddFragment(AlbumsFragment, GetText(Resource.String.Lbl_Albums));
                adapter.AddFragment(LikedFragment, GetText(Resource.String.Lbl_Liked));
                adapter.AddFragment(PlaylistFragment, GetText(Resource.String.Lbl_Playlist));
                adapter.AddFragment(SongsFragment, GetText(Resource.String.Lbl_Songs));
                adapter.AddFragment(StoreFragment, GetText(Resource.String.Lbl_Store_Title));
                adapter.AddFragment(StationsFragment, GetText(Resource.String.Lbl_Stations));

                //ViewPagerView.CurrentItem = adapter.Count;
                ViewPagerView.OffscreenPageLimit = adapter.Count;
                ViewPagerView.PageSelected      += ViewPagerViewOnPageSelected;
                ViewPagerView.Adapter            = adapter;

                Tabs.SetupWithViewPager(ViewPagerView);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }