void SetupDrawerContent(SupportDesign.NavigationView _navigationView)
 {
     try
     {
         _navigationView.NavigationItemSelected += (object sender, SupportDesign.NavigationView.NavigationItemSelectedEventArgs e) =>
         {
             e.MenuItem.SetChecked(true);
             drawerLayout.CloseDrawers();
         };
     }
     catch (Exception ex)
     {
         var msg = ex.Message;
     }
 }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            toolbar        = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.toolbar);
            drawerLayout   = (Android.Support.V4.Widget.DrawerLayout)FindViewById(Resource.Id.drawerLayout);
            navigationView = (Android.Support.Design.Widget.NavigationView)FindViewById(Resource.Id.navView);
            navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;


            //Setup Toolbar

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Topics";
            Android.Support.V7.App.ActionBar actionBar = SupportActionBar;
            actionBar.SetHomeAsUpIndicator(Resource.Drawable.menuaction);
            actionBar.SetDisplayHomeAsUpEnabled(true);


            // View Setup
            historyLayout     = (LinearLayout)FindViewById(Resource.Id.historyLayout);
            spaceLayout       = (LinearLayout)FindViewById(Resource.Id.spaceLayout);
            geographyLayout   = (LinearLayout)FindViewById(Resource.Id.geographyLayout);
            programmingLayout = (LinearLayout)FindViewById(Resource.Id.programmingLayout);
            businessLayout    = (LinearLayout)FindViewById(Resource.Id.businessLayout);
            engineeringLayout = (LinearLayout)FindViewById(Resource.Id.engineeringLayout);



            // Click Event Handlers

            historyLayout.Click     += HistoryLayout_Click;
            geographyLayout.Click   += GeographyLayout_Click;
            spaceLayout.Click       += SpaceLayout_Click;
            programmingLayout.Click += ProgrammingLayout_Click;
            businessLayout.Click    += BusinessLayout_Click;
            engineeringLayout.Click += EngineeringLayout_Click;
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            /*
             * SetContentView(Resource.Id.DrawerLayoutMenuOne);
             * drawerLayout = FindViewById<SupportV4DrawerLayout.DrawerLayout>(Resource.Id.DrawerLayoutMenuOne);
             * navigationView = FindViewById<SupportDesign.NavigationView>(Resource.Id.DrawerLayoutMenuOneNavigationView);
             * var toolBar = FindViewById<SupportV7ToolBar.Toolbar>(Resource.Id.DrawerLayoutMenuOneToolBar);
             *
             * SetSupportActionBar(toolBar);
             * SupportActionBar.SetDisplayHomeAsUpEnabled(true);
             * SupportActionBar.SetDisplayShowTitleEnabled(false);
             * SupportActionBar.SetHomeButtonEnabled(true);
             * SupportActionBar.SetHomeAsUpIndicator(Resource.Mipmap.HamBurgerWhite);
             */

            try
            {
                SetContentView(Resource.Layout.DrawerLayoutMenuOneAXML);
                drawerLayout   = FindViewById <SupportV4DrawerLayout.DrawerLayout>(Resource.Id.DrawerLayoutMenuOne);
                navigationView = FindViewById <SupportDesign.NavigationView>(Resource.Id.DrawerLayoutMenuOneNavigationView);
                var toolBar = FindViewById <SupportV7ToolBar.Toolbar>(Resource.Id.DrawerLayoutMenuOneToolBar);

                SetSupportActionBar(toolBar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetDisplayShowTitleEnabled(false);
                SupportActionBar.SetHomeButtonEnabled(true);
                SupportActionBar.SetHomeAsUpIndicator(Resource.Mipmap.HamBurgerWhite);
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                System.Console.Write(ex.StackTrace);
            }
        }
        //SupportV7ToolBar.Toolbar toolbar;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.DrawerLayoutMenuTwoAXML);
            drawerLayout = FindViewById <SupportV4DrawerLayout.DrawerLayout>(Resource.Id.MenuTwoDrawerLayout);

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

            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Mipmap.HamBurgerWhite);

            var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.menu_two_drawer_open, Resource.String.menu_two_drawer_close);

            drawerLayout.SetDrawerListener(drawerToggle);
            drawerToggle.SyncState();

            navigationView = FindViewById <SupportDesign.NavigationView>(Resource.Id.MenuTowNavigationView);
            SetupDrawerContent(navigationView);
        }