Ejemplo n.º 1
0
        private void ViewPager_PageSelected(object sender, PageSelectedEventArgs e)
        {
            if (e.Position != 0)
            {
                TitleInputFragment fragment = (TitleInputFragment)fragments[0];
                fragment.HideKeyboard();
            }

            if (e.Position == 1)
            {
                TopRatedFragment fragment = (TopRatedFragment)fragments[e.Position];
                fragment.GenerateTopRatedAsync();
            }
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var topRatedFragment   = new TopRatedFragment(MovieService);
            var titleInputFragment = new TitleInputFragment(MovieService);
            var fragments          = new Fragment[]
            {
                titleInputFragment,
                topRatedFragment
            };
            var titles = CharSequence.ArrayFromStringArray(new[] { SEARCHBARTAB, TOPRATEDTAB });


            var viewPager = FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, fragments, titles);

            var tabLayout = this.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);

            var toolbar = this.FindViewById <Toolbar>(Resource.Id.toolbar);

            this.SetActionBar(toolbar);
            tabLayout.TabSelected += (object sender, TabLayout.TabSelectedEventArgs e) =>
            {
                if (e.Tab.Text.Equals(TOPRATEDTAB))
                {
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    imm.HideSoftInputFromWindow(toolbar.WindowToken, 0);
                    topRatedFragment.LoadTopRatedMovies();
                }
            };
            this.ActionBar.Title = TABTITLE;
        }