protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_sample_dark_toolbar); var toolbar = this.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); this.SetSupportActionBar(toolbar); // Create a few sample profile // NOTE you have to define the loader logic too. See the CustomApplication for more details var profile = new ProfileDrawerItem().WithName("Mike Penz").WithEmail("*****@*****.**").WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"); var profile2 = new ProfileDrawerItem().WithName("Bernat Borras").WithEmail("*****@*****.**").WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460")); var profile3 = new ProfileDrawerItem().WithName("Max Muster").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile2)); var profile4 = new ProfileDrawerItem().WithName("Felix House").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile3)); var profile5 = new ProfileDrawerItem().WithName("Mr. X").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile4)).WithIdentifier(4); var profile6 = new ProfileDrawerItem().WithName("Batman").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile5)); headerResult = new AccountHeaderBuilder() .WithActivity(this) .WithHeaderBackground(Resource.Drawable.header) .AddProfiles( profile, profile2, profile3, profile4, profile5, profile6, //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account) new ProfileSettingDrawerItem().WithName("Add Account").WithDescription("Add new GitHub Account").WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdAdd) .PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text)).WithIdentifier(PROFILE_SETTING), new ProfileSettingDrawerItem().WithName("Manage Account").WithIcon(GoogleMaterial.Icon.GmdSettings) ) .WithOnAccountHeaderListener(this) .WithSavedInstance(savedInstanceState) .Build(); var item1 = new PrimaryDrawerItem(); item1.WithName(Resource.String.drawer_item_compact_header); item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny); item1.WithIdentifier(1); item1.WithCheckable(false); var item2 = new PrimaryDrawerItem(); item2.WithName(Resource.String.drawer_item_action_bar); item2.WithIcon(FontAwesome.Icon.FawHome); item2.WithIdentifier(2); item2.WithCheckable(false); var item3 = new PrimaryDrawerItem(); item3.WithName(Resource.String.drawer_item_multi_drawer); item3.WithIcon(FontAwesome.Icon.FawGamepad); item3.WithIdentifier(3); item3.WithCheckable(false); var item4 = new PrimaryDrawerItem(); item4.WithName(Resource.String.drawer_item_non_translucent_status_drawer); item4.WithIcon(FontAwesome.Icon.FawEye); item4.WithIdentifier(4); item4.WithCheckable(false); var item5 = new PrimaryDrawerItem(); item5.WithDescription("A more complex sample"); item5.WithName(Resource.String.drawer_item_complex_header_drawer); item5.WithIcon(GoogleMaterial.Icon.GmdAdb); item5.WithIdentifier(5); item5.WithCheckable(false); var item6 = new PrimaryDrawerItem(); item6.WithName(Resource.String.drawer_item_simple_fragment_drawer); item6.WithIcon(GoogleMaterial.Icon.GmdStyle); item6.WithIdentifier(6); item6.WithCheckable(false); var item7 = new PrimaryDrawerItem(); item7.WithName(Resource.String.drawer_item_embedded_drawer_dualpane); item7.WithIcon(GoogleMaterial.Icon.GmdBatteryChargingFull); item7.WithIdentifier(7); item7.WithCheckable(false); var item8 = new PrimaryDrawerItem(); item8.WithName(Resource.String.drawer_item_fullscreen_drawer); item8.WithIcon(GoogleMaterial.Icon.GmdStyle); item8.WithIdentifier(8); item8.WithCheckable(false); var item9 = new PrimaryDrawerItem(); item9.WithName(Resource.String.drawer_item_custom_container_drawer); item9.WithIcon(GoogleMaterial.Icon.GmdMyLocation); item9.WithIdentifier(9); item9.WithCheckable(false); var item10 = new SecondaryDrawerItem(); item10.WithName(Resource.String.drawer_item_open_source); item10.WithIcon(FontAwesome.Icon.FawGithub); item10.WithIdentifier(20); item10.WithCheckable(false); var item11 = new SecondaryDrawerItem(); item11.WithName(Resource.String.drawer_item_contact); item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill); item11.WithIdentifier(10); item11.WithTag("Bullhorn"); var item12 = new SwitchDrawerItem(); item12.WithName("Switch"); item12.WithIcon(Octicons.Icon.OctTools); item12.WithChecked(true); item12.WithOnCheckedChangeListener(this); var item13 = new SwitchDrawerItem(); item13.WithName("Switch2"); item13.WithIcon(Octicons.Icon.OctTools); item13.WithChecked(true); item13.WithOnCheckedChangeListener(this); var item14 = new ToggleDrawerItem(); item14.WithName("Toggle"); item14.WithIcon(Octicons.Icon.OctTools); item14.WithChecked(true); item14.WithOnCheckedChangeListener(this); result = new DrawerBuilder() .WithActivity(this) .WithToolbar(toolbar) .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header .AddDrawerItems( item1, item2, item3, item4, item5, item6, item7, item8, item9, new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header), item10, item11, new DividerDrawerItem(), item12, item13, item14 ) // add the items we want to use With our Drawer .WithOnDrawerItemClickListener(this) .WithSavedInstance(savedInstanceState) .WithShowDrawerOnFirstLaunch(true) .Build(); if (savedInstanceState == null) { // set the selection to the item with the identifier 10 result.SetSelectionByIdentifier(10, false); //set the active profile headerResult.SetActiveProfile(profile3); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_sample_dark_toolbar); var toolbar = this.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); this.SetSupportActionBar(toolbar); // Create a few sample profile // NOTE you have to define the loader logic too. See the CustomApplication for more details var profile = new ProfileDrawerItem().WithName("Mike Penz").WithEmail("*****@*****.**").WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"); var profile2 = new ProfileDrawerItem().WithName("Bernat Borras").WithEmail("*****@*****.**").WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460")); var profile3 = new ProfileDrawerItem().WithName("Max Muster").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile2)); var profile4 = new ProfileDrawerItem().WithName("Felix House").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile3)); var profile5 = new ProfileDrawerItem().WithName("Mr. X").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile4)).WithIdentifier(4); var profile6 = new ProfileDrawerItem().WithName("Batman").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile5)); headerResult = new AccountHeaderBuilder() .WithActivity(this) .WithHeaderBackground(Resource.Drawable.header) .AddProfiles( profile, profile2, profile3, profile4, profile5, profile6, //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account) new ProfileSettingDrawerItem().WithName("Add Account").WithDescription("Add new GitHub Account").WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdAdd) .PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text)).WithIdentifier(PROFILE_SETTING), new ProfileSettingDrawerItem().WithName("Manage Account").WithIcon(GoogleMaterial.Icon.GmdSettings) ) .WithOnAccountHeaderListener(this) .WithSavedInstance(savedInstanceState) .Build(); var item1 = new PrimaryDrawerItem(); item1.WithName(Resource.String.drawer_item_compact_header); item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny); item1.WithIdentifier(1); item1.WithCheckable(false); var item2 = new PrimaryDrawerItem(); item2.WithName(Resource.String.drawer_item_action_bar); item2.WithIcon(FontAwesome.Icon.FawHome); item2.WithIdentifier(2); item2.WithCheckable(false); var item3 = new PrimaryDrawerItem(); item3.WithName(Resource.String.drawer_item_multi_drawer); item3.WithIcon(FontAwesome.Icon.FawGamepad); item3.WithIdentifier(3); item3.WithCheckable(false); var item4 = new PrimaryDrawerItem(); item4.WithName(Resource.String.drawer_item_non_translucent_status_drawer); item4.WithIcon(FontAwesome.Icon.FawEye); item4.WithIdentifier(4); item4.WithCheckable(false); var item5 = new PrimaryDrawerItem(); item5.WithDescription("A more complex sample"); item5.WithName(Resource.String.drawer_item_complex_header_drawer); item5.WithIcon(GoogleMaterial.Icon.GmdAdb); item5.WithIdentifier(5); item5.WithCheckable(false); var item6 = new PrimaryDrawerItem(); item6.WithName(Resource.String.drawer_item_simple_fragment_drawer); item6.WithIcon(GoogleMaterial.Icon.GmdStyle); item6.WithIdentifier(6); item6.WithCheckable(false); var item7 = new PrimaryDrawerItem(); item7.WithName(Resource.String.drawer_item_embedded_drawer_dualpane); item7.WithIcon(GoogleMaterial.Icon.GmdBatteryChargingFull); item7.WithIdentifier(7); item7.WithCheckable(false); var item8 = new PrimaryDrawerItem(); item8.WithName(Resource.String.drawer_item_fullscreen_drawer); item8.WithIcon(GoogleMaterial.Icon.GmdStyle); item8.WithIdentifier(8); item8.WithCheckable(false); var item9 = new PrimaryDrawerItem(); item9.WithName(Resource.String.drawer_item_custom_container_drawer); item9.WithIcon(GoogleMaterial.Icon.GmdMyLocation); item9.WithIdentifier(9); item9.WithCheckable(false); var item10 = new SecondaryDrawerItem(); item10.WithName(Resource.String.drawer_item_open_source); item10.WithIcon(FontAwesome.Icon.FawGithub); item10.WithIdentifier(20); item10.WithCheckable(false); var item11 = new SecondaryDrawerItem(); item11.WithName(Resource.String.drawer_item_contact); item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill); item11.WithIdentifier(10); item11.WithTag("Bullhorn"); var item12 = new SwitchDrawerItem(); item12.WithName("Switch"); item12.WithIcon(Octicons.Icon.OctTools); item12.WithChecked(true); item12.WithOnCheckedChangeListener(this); var item13 = new SwitchDrawerItem(); item13.WithName("Switch2"); item13.WithIcon(Octicons.Icon.OctTools); item13.WithChecked(true); item13.WithOnCheckedChangeListener(this); var item14 = new ToggleDrawerItem(); item14.WithName("Toggle"); item14.WithIcon(Octicons.Icon.OctTools); item14.WithChecked(true); item14.WithOnCheckedChangeListener(this); result = new DrawerBuilder() .WithActivity(this) .WithToolbar(toolbar) .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header .AddDrawerItems( item1, item2, item3, item4, item5, item6, item7, item8, item9, new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header), item10, item11, new DividerDrawerItem(), item12, item13, item14 ) // add the items we want to use With our Drawer .WithOnDrawerItemClickListener(this) .WithSavedInstance(savedInstanceState) .WithShowDrawerOnFirstLaunch(true) .Build(); if (savedInstanceState == null) { // set the selection to the item with the identifier 10 result.SetSelectionByIdentifier(10, false); //set the active profile headerResult.SetActiveProfile(profile3); } }