public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); var appBar = view.FindViewById <BottomAppBar>(Resource.Id.fragment_main_bottomAppBar); if (appBar != null) { appBar.NavigationClick += (sender, args) => { var fragment = new BottomNavigationDrawerFragment(); fragment.Show(ChildFragmentManager, fragment.Tag); }; } var topAppBar = view.FindViewById <MaterialToolbar>(Resource.Id.fragment_main_topAppBar); if (topAppBar != null) { topAppBar.NavigationClick += (sender, args) => { _drawerLayout = Activity.FindViewById <DrawerLayout>(Resource.Id.fragment_main_drawer_layout); _drawerLayout.OpenDrawer((int)GravityFlags.Start); }; } var button = view.FindViewById <FloatingActionButton>(Resource.Id.fragment_main_add_button); button.Click += (sender, args) => { var fragment = new CreateEventFragment(); fragment.Show(ChildFragmentManager, fragment.Tag); }; _tabLayout = view.FindViewById <TabLayout>(Resource.Id.fragment_main_tab_layout); _viewPager2 = view.FindViewById <ViewPager2>(Resource.Id.fragment_main_view_pager); _viewPager2.Adapter = new ViewPagerAdapter(ChildFragmentManager, Lifecycle); _tabLayoutMediator = new TabLayoutMediator(_tabLayout, _viewPager2, this); _tabLayoutMediator.Attach(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); var toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = "GPS tracker"; var viewPager = FindViewById <ViewPager2>(Resource.Id.viewPager1); var pagerAdapter = new CustomPagerAdapter(this); viewPager.OffscreenPageLimit = 3; viewPager.Adapter = pagerAdapter; var tabLayout = FindViewById <TabLayout>(Resource.Id.tabLayout); var tabLayoutMediator = new TabLayoutMediator(tabLayout, viewPager, new TabConfigurationStrategy()); tabLayoutMediator.Attach(); }