Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            var toolBar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolBar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.menu4);
            drawerLayout = FindViewById <Android.Support.V4.Widget.DrawerLayout>(Resource.Id.drawer_layout);
            navView      = FindViewById <NavigationView>(Resource.Id.nav_view);
            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
            HomeFragment home = new HomeFragment();

            transaction.Add(Resource.Id.framelayout, home).Commit();

            setupDrawerContent(navView);
        }
Exemplo n.º 2
0
        void setupDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (sender, e) => {
                e.MenuItem.SetChecked(true);
                Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_main:
                    HomeFragment home = new HomeFragment();
                    transaction1.Replace(Resource.Id.framelayout, home).AddToBackStack(null).Commit();
                    break;

                    //case Android.Resource.Id.nav_list:
                    //    VideoFragment video = new VideoFragment();
                    //    transaction1.Replace(Resource.Id.framelayout, video).AddToBackStack(null).Commit();
                    //    break;
                }
                drawerLayout.CloseDrawers();
            };
        }