Ejemplo n.º 1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.menu_schedule_datetimepicker:
                DateTimePickerFragment frag = DateTimePickerFragment.NewInstance(delegate(DateTime time)
                {
                    viewPager.Adapter = null;
                    adapter           = new ScheduleFragmentAdapter(((AppCompatActivity)Activity).SupportFragmentManager, tabLayout.TabCount, time, time.DayOfYear);
                    viewPager.Adapter = adapter;
                    lastDate          = time;
                }, lastDate);
                frag.Show(Activity.FragmentManager, DateTimePickerFragment.TAG);
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
Ejemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = inflater.Inflate(Resource.Layout.fragment_schedule, container, false);

            HasOptionsMenu = true;

            tabLayout = view.FindViewById <TabLayout>(Resource.Id.tablayout_schedule);
            tabLayout.AddTab(tabLayout.NewTab().SetText(GetString(Resource.String.currentweek_tab)));
            tabLayout.AddTab(tabLayout.NewTab().SetText(GetString(Resource.String.nextweek_tab)));
            tabLayout.SetForegroundGravity(TabLayout.GravityFill);

            adapter = new ScheduleFragmentAdapter(((AppCompatActivity)Activity).SupportFragmentManager, tabLayout.TabCount, DateTime.Today);

            viewPager         = view.FindViewById <ViewPager>(Resource.Id.viewpager_schedule);
            viewPager.Adapter = adapter;
            viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

            tabLayout.TabSelected += (object sender, TabLayout.TabSelectedEventArgs e) =>
            {
                viewPager.CurrentItem = e.Tab.Position;
            };

            return(view);
        }