protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Menu); _title = _drawerTitle = Title; _menuTitles = Resources.GetStringArray(Resource.Array.MenuArray); _drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); _drawerList = FindViewById<ListView>(Resource.Id.left_drawer); _drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityFlags.Start); _drawerList.Adapter = new ArrayAdapter<string>(this, Resource.Layout.drawer_item, _menuTitles); _drawerList.ItemClick += (sender, args) => SelectItem(args.Position); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent))); //DrawerToggle is the animation that happens with the indicator next to the //ActionBar icon. You can choose not to use this. _drawerToggle = new MyActionBarDrawerToggle(this, _drawer, Resource.Drawable.ic_drawer_light, Resource.String.DrawerOpen, Resource.String.DrawerClose); //You can alternatively use _drawer.DrawerClosed here _drawerToggle.DrawerClosed += delegate { ActionBar.Title = _title; ActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent))); InvalidateOptionsMenu(); }; //You can alternatively use _drawer.DrawerOpened here _drawerToggle.DrawerOpened += delegate { ActionBar.Title = _drawerTitle; InvalidateOptionsMenu(); }; _drawer.SetDrawerListener(_drawerToggle); if (null == savedInstanceState) SelectItem(0); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Menu); Intent t = this.Intent; bool firstload=t.GetBooleanExtra("FirstLoad",false); if (firstload == true) { } User sv = BUser.GetMainUser (SQLite_Android.GetConnection ()); _title = _drawerTitle = Title; _menuTitles = Resources.GetStringArray(Resource.Array.MenuArray); _drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); _drawerList = FindViewById<ListView>(Resource.Id.left_drawer); _drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityFlags.Start); View header = this.LayoutInflater.Inflate (Resource.Layout.DrawerHeader, null); header.FindViewById<TextView> (Resource.Id.txtTenSV).Text=sv.Hoten; header.FindViewById<TextView> (Resource.Id.txtmasv).Text=sv.Id; _drawerList.AddHeaderView (header); List<DrawerItem> listItems = new List<DrawerItem> (); // listItems.Add(new DrawerItem(namesv,Resource.Drawable.user,true)); listItems.Add(new DrawerItem("Lịch Học",0,false,true)); listItems.Add(new DrawerItem("Theo Học Kỳ",Resource.Drawable.Iclichhoc,true,false)); listItems.Add(new DrawerItem("Theo Tuần",Resource.Drawable.calendar,false,false)); listItems.Add(new DrawerItem("Điểm Thi",0,false,true)); listItems.Add(new DrawerItem("Theo Học Kỳ",Resource.Drawable.Icdiemthi,true,false)); listItems.Add(new DrawerItem("Tất Cả",Resource.Drawable.IcAdiemthi,false,false)); listItems.Add(new DrawerItem("Học Phí-Lịch Thi",0,false,true)); listItems.Add(new DrawerItem("Lịch Thi",Resource.Drawable.Iclichthi,true,false)); listItems.Add(new DrawerItem("Học Phí",Resource.Drawable.Ichocphi,false,false)); listItems.Add(new DrawerItem("Ứng Dụng",0,false,true)); listItems.Add(new DrawerItem("Cài đặt",Resource.Drawable.Icsettings,true,false)); listItems.Add (new DrawerItem ("Đăng xuất", Resource.Drawable.signout,false,false)); _drawerList.Adapter = new CustomDrawerAdapter (this, listItems); _drawerList.ItemClick += (sender, args) => SelectItem(args.Position); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent))); //DrawerToggle is the animation that happens with the indicator next to the //ActionBar icon. You can choose not to use this. _drawerToggle = new MyActionBarDrawerToggle(this, _drawer, Resource.Drawable.ic_menu_white_18dp, Resource.String.DrawerOpen, Resource.String.DrawerClose); //You can alternatively use _drawer.DrawerClosed here _drawerToggle.DrawerClosed += delegate { ActionBar.Title = _title; ActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent))); InvalidateOptionsMenu(); }; //You can alternatively use _drawer.DrawerOpened here _drawerToggle.DrawerOpened += delegate { ActionBar.Title = _drawerTitle; InvalidateOptionsMenu(); }; _drawer.SetDrawerListener(_drawerToggle); this.ActionBar.SetDisplayHomeAsUpEnabled(true); this.ActionBar.SetHomeButtonEnabled(true); if (null == savedInstanceState) { SelectItem (2); previousItemChecked = 2; } }