private void addFooterItems() { drawer.addItems(new DividerDrawerItem(), new PrimaryDrawerItem() .withName(R.string.folders_action) .withIcon(iconFolderResId) .withIdentifier(DRAWER_ID_FOLDERS) .withSelectable(false), new PrimaryDrawerItem() .withName(R.string.preferences_action) .withIcon(getResId(R.attr.iconActionSettings)) .withIdentifier(DRAWER_ID_PREFERENCES) .withSelectable(false) ); }
tb.setTitleTextColor(Color.parseColor("#FFFFFF")); PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName("Home"); PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(2).withName("Permissions");
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_custom_container_dark_toolbar); // Handle Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setTitle(R.string.drawer_item_custom_container_drawer); //Create the drawer result = new DrawerBuilder(this) //this layout have to contain child layouts .withRootView(R.id.drawer_container) .withToolbar(toolbar) .withDisplayBelowStatusBar(false) .withActionBarDrawerToggleAnimated(true) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn) ) .withSavedInstance(savedInstanceState) .build(); }
private PrimaryDrawerItem drawerItemForClass(AppCompatActivity activeActivity, Class<?> targetActivityClass, @StringRes int targetActivityTitleRessource, @DrawableRes int iconResource) { return new PrimaryDrawerItem() .withName(activeActivity.getString(targetActivityTitleRessource)) .withSelectable(false) .withSelectedTextColorRes(COLOR_ICON_PRIMARY_ACTIVE) .withIcon(iconResource) .withIconColorRes(COLOR_ICON_PRIMARY) .withIconTintingEnabled(true) .withSelectedIconColorRes(COLOR_ICON_PRIMARY_ACTIVE) .withTag(targetActivityClass) .withIdentifier(targetActivityClass.hashCode()); } private SecondaryDrawerItem secondaryDrawerItemForClass(AppCompatActivity activeActivity, Class<?> targetActivityClass, @StringRes int targetActivityTitleRessource, @DrawableRes int iconResource) {
.build(); refreshDrawerItem = new PrimaryDrawerItem() .withName(getString(R.string.action_sync)) .withSelectable(false) .withIconTintingEnabled(true) .withIcon(R.drawable.ic_refresh) .withIdentifier(REFRESH_DRAWER_ITEM_ID) .withTag((Runnable) () -> SyncService.startSync(ListActivity.this)); IDrawerItem settingsDrawerItem = new PrimaryDrawerItem() .withName(R.string.settings) .withIcon(R.drawable.ic_settings) .withIconTintingEnabled(true) .withSelectable(false) .withTag((Runnable) () -> { startDrawer.closeDrawer(); Intent settingsIntent = new Intent(ListActivity.this, SettingsActivity.class);
.withAccountHeader(header) .addDrawerItems( new PrimaryDrawerItem().withIdentifier(ID_RENAME_PROJECT).withName(R.string.rename_pro).withIcon(FontAwesome.Icon.faw_i_cursor).withSelectable(false), new PrimaryDrawerItem().withIdentifier(ID_DELETE_PROJECT).withName(R.string.delete_pro).withIcon(FontAwesome.Icon.faw_trash).withSelectable(false), new DividerDrawerItem(), new PrimaryDrawerItem().withIdentifier(ID_ALL_PROJECTS).withName(R.string.all_pro).withIcon(GoogleMaterial.Icon.gmd_inbox).withSelectable(false), new PrimaryDrawerItem().withIdentifier(ID_NEW_PROJECT_AND_SWITCH).withName(R.string.new_pro).withIcon(FontAwesome.Icon.faw_plus).withSelectable(false), new DividerDrawerItem(), new ExpandableDrawerItem().withName(R.string.settings).withIcon(FontAwesome.Icon.faw_gear).withSelectable(false).withSubItems( doneSwitch, bigTextSwitch, darkSwitch), new ExpandableDrawerItem().withName(R.string.help_feedback).withIcon(FontAwesome.Icon.faw_question_circle).withSelectable(false).withSubItems( new SecondaryDrawerItem().withName(R.string.see_app_intro).withLevel(2).withIcon(GoogleMaterial.Icon.gmd_camera_rear).withIdentifier(ID_SEE_APP_INTRO_AGAIN).withSelectable(false), new SecondaryDrawerItem().withName(R.string.activate_tuto).withLevel(2).withIcon(GoogleMaterial.Icon.gmd_info).withIdentifier(ID_ACTIVATE_TUTORIAL_AGAIN).withSelectable(false), new SecondaryDrawerItem().withName(R.string.rate_app).withLevel(2).withIcon(GoogleMaterial.Icon.gmd_star).withIdentifier(ID_RATE_IDEAS_TRACKER).withSelectable(false), new SecondaryDrawerItem().withName(R.string.feedback).withLevel(2).withIcon(GoogleMaterial.Icon.gmd_bug).withIdentifier(ID_SEND_FEEDBACK).withSelectable(false), new SecondaryDrawerItem().withName(R.string.source_code).withLevel(2).withIcon(GoogleMaterial.Icon.gmd_github).withIdentifier(ID_SOURCE_CODE).withSelectable(false)) mColorItem1 = new PrimaryDrawerItem() .withIdentifier(ID_PRIMARY_COLOR) .withName(R.string.primary_col) .withIcon(FontAwesome.Icon.faw_paint_brush) .withIconColor(mPrimaryColor).withSelectable(false); mColorItem2 = new PrimaryDrawerItem() .withIdentifier(ID_SECONDARY_COLOR) .withName(R.string.secondary_col) .withIcon(FontAwesome.Icon.faw_paint_brush) .withIconColor(mSecondaryColor) .withSelectable(false);
PrimaryDrawerItem aboutItem = new PrimaryDrawerItem() .withName(getString(R.string.about)) .withSelectable(false) .withOnDrawerItemClickListener((view, position, drawerItem) -> { new LibsBuilder() .withActivityTitle(getString(R.string.about)) return false; }) .withIcon(GoogleMaterial.Icon.gmd_info); myAudioItem = new PrimaryDrawerItem() .withName(R.string.my_audio) .withIcon(GoogleMaterial.Icon.gmd_music_note) .withOnDrawerItemClickListener((view, position, drawerItem) -> { showMyAudioFragment(); return true; }) .withSetSelected(true); popularItem = new PrimaryDrawerItem() .withName(R.string.popular) .withIcon(GoogleMaterial.Icon.gmd_show_chart) .withOnDrawerItemClickListener(((view, position, drawerItem) -> { showPopularFragment(); return true; })); playbackQueueItem = new PrimaryDrawerItem()
drawer.removeItem(item.getIdentifier()); PrimaryDrawerItem item = new PrimaryDrawerItem() .withIdentifier(playlist.getId()) .withName(playlist.getTitle()) .withTag(playlist) .withOnDrawerItemClickListener((view, position, drawerItem) -> { showPlaylistFragment(playlist); return false;
/** * @return the list of items */ public ArrayList<IDrawerItem> getDrawerItems() { // The menu items in the drawer ArrayList<IDrawerItem> items = new ArrayList<>(); // Dashboard //if you want to update the items at a later time it is recommended to keep it in a variable //@formatter:off items.add(new PrimaryDrawerItem() .withName(MenuItem.MENU_ITEM1.mLabel).withIcon(Octicons.Icon.oct_dashboard) .withIconColorRes(R.color.menu_item_1).withSelectedIconColorRes(R.color.menu_item_1)); items.add(new PrimaryDrawerItem() .withName(MenuItem.MENU_ITEM2.mLabel).withIcon(Octicons.Icon.oct_graph) .withIconColorRes(R.color.menu_item_2).withSelectedIconColorRes(R.color.menu_item_2)); items.add(new PrimaryDrawerItem() .withName(MenuItem.MENU_ITEM3.mLabel).withIcon(FontAwesome.Icon.faw_sign_out) .withIconColorRes(R.color.menu_item_3).withSelectedIconColorRes(R.color.menu_item_3)); items.add(new PrimaryDrawerItem() .withName(MenuItem.MENU_ITEM4.mLabel).withIcon(FontAwesome.Icon.faw_sign_out) .withIconColorRes(R.color.menu_item_4).withSelectedIconColorRes(R.color.menu_item_4)); items.add(new PrimaryDrawerItem() .withName(MenuItem.MENU_ITEM5.mLabel).withIcon(FontAwesome.Icon.faw_sign_out) .withIconColorRes(R.color.menu_item_5).withSelectedIconColorRes(R.color.menu_item_5)); //@formatter:on decorate(items); return items; }
new PrimaryDrawerItem() .withEnabled(false) .withName(R.string.no_folders_to_show) ); } else {
@NonNull protected List<IDrawerItem> drawerItems() { return Arrays.<IDrawerItem>asList( new PrimaryDrawerItem() .withName(R.string.drawer_item_recognize_tags) .withOnDrawerItemClickListener(goToActivityListener(RecognizeConceptsActivity.class)) ); }
@Override protected List<IDrawerItem> reloadDrawerItems(Realm realm, boolean showOnlyUnread) { List<Feed> feeds = state.getStartDrawerItem().getFeeds(realm, showOnlyUnread); List<IDrawerItem> drawerItems = new ArrayList<>((feeds != null ? feeds.size() : 0) + 1); if (state.isFeedSelected()) return drawerItems; drawerItems.add(new SectionDrawerItem() .withDivider(false) .withName(state.getStartDrawerItem().getName())); if (feeds != null) { for (Feed feed : feeds) { PrimaryDrawerItem drawerItem = new TreeItemDrawerItem(feed); drawerItem.withIdentifier(feed.getId()); drawerItem.withBadge(feed.getUnreadCount()); drawerItem.withSetSelected(state.getEndDrawerItem() != null && state.getEndDrawerItem().getId() == feed.getId()); drawerItems.add(drawerItem); } } return drawerItems; }
.withTranslucentStatusBar(false) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment // don't look at this layout it's just a listView to show how to handle the keyboard View view = inflater.inflate(R.layout.fragment_simple_sample, container, false); result = new DrawerBuilder() .withActivity(getActivity()) .withRootView((ViewGroup) view.findViewById(R.id.rootView)) .withDisplayBelowStatusBar(false) .withSavedInstance(savedInstanceState) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1), new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye) ) .buildForFragment(); TextView textView = (TextView) view.findViewById(R.id.title); textView.setText(getArguments().getString(KEY_TITLE)); result.getDrawerLayout().setFitsSystemWindows(false); result.getSlider().setFitsSystemWindows(false); return view; }
@Override protected void onCreate(Bundle savedInstanceState) { //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_actionbar); setTitle(R.string.drawer_item_action_bar_drawer); // Handle Toolbar result = new DrawerBuilder() .withActivity(this) .withSavedInstance(savedInstanceState) .withDisplayBelowStatusBar(false) .withTranslucentStatusBar(false) .withDrawerLayout(R.layout.material_drawer_fits_not) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem instanceof Nameable) { Toast.makeText(ActionBarActivity.this, ((Nameable) drawerItem).getName().getText(ActionBarActivity.this), Toast.LENGTH_SHORT).show(); } return false; } }).build(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(false); }
.withShowDrawerOnFirstLaunch(true) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.sample_icon_grid).withDescription(R.string.sample_icon_grid_descr).withSelectable(false).withIdentifier(8).withIcon(MaterialDesignIconic.Icon.gmi_grid), new PrimaryDrawerItem().withName(R.string.sample_simple_item_list).withDescription(R.string.sample_simple_item_list_descr).withSelectable(false).withIdentifier(6).withIcon(MaterialDesignIconic.Icon.gmi_format_align_justify), new PrimaryDrawerItem().withName(R.string.sample_image_list).withDescription(R.string.sample_image_list_descr).withSelectable(false).withIdentifier(5).withIcon(MaterialDesignIconic.Icon.gmi_wallpaper), new PrimaryDrawerItem().withName(R.string.sample_multi_select).withDescription(R.string.sample_multi_select_descr).withSelectable(false).withIdentifier(1).withIcon(MaterialDesignIconic.Icon.gmi_select_all), new PrimaryDrawerItem().withName(R.string.sample_collapsible).withDescription(R.string.sample_collapsible_descr).withSelectable(false).withIdentifier(2).withIcon(MaterialDesignIconic.Icon.gmi_check_all), new PrimaryDrawerItem().withName(R.string.sample_sticky_header).withDescription(R.string.sample_sticky_header_descr).withSelectable(false).withIdentifier(3).withIcon(MaterialDesignIconic.Icon.gmi_format_align_left), new PrimaryDrawerItem().withName(R.string.sample_advanced).withDescription(R.string.sample_advanced_descr).withSelectable(false).withIdentifier(4).withIcon(MaterialDesignIconic.Icon.gmi_coffee), new PrimaryDrawerItem().withName(R.string.sample_model_item).withDescription(R.string.sample_model_item_descr).withSelectable(false).withIdentifier(7).withIcon(MaterialDesignIconic.Icon.gmi_font), new PrimaryDrawerItem().withName(R.string.sample_multi_model_item).withDescription(R.string.sample_multi_model_item_descr).withSelectable(false).withIdentifier(9).withIcon(MaterialDesignIconic.Icon.gmi_format_list_numbered), new PrimaryDrawerItem().withName(R.string.sample_checkbox_item).withDescription(R.string.sample_checkbox_item_descr).withSelectable(false).withIdentifier(10).withIcon(CommunityMaterial.Icon.cmd_checkbox_marked), new PrimaryDrawerItem().withName(R.string.sample_radiobutton_item).withDescription(R.string.sample_radiobutton_item_descr).withSelectable(false).withIdentifier(11).withIcon(CommunityMaterial.Icon.cmd_radiobox_marked), new PrimaryDrawerItem().withName(R.string.sample_swipe_list).withDescription(R.string.sample_swipe_list_descr).withSelectable(false).withIdentifier(12).withIcon(MaterialDesignIconic.Icon.gmi_format_align_left), new PrimaryDrawerItem().withName(R.string.sample_endless_scroll_list).withDescription(R.string.sample_endless_scroll_list_descr).withSelectable(false).withIdentifier(13).withIcon(MaterialDesignIconic.Icon.gmi_long_arrow_down), new PrimaryDrawerItem().withName(R.string.sample_sort).withDescription(R.string.sample_sort_descr).withSelectable(false).withIdentifier(14).withIcon(MaterialDesignIconic.Icon.gmi_sort_by_alpha), new PrimaryDrawerItem().withName(R.string.sample_mopub).withDescription(R.string.sample_mopub_descr).withSelectable(false).withIdentifier(15).withIcon(MaterialDesignIconic.Icon.gmi_accounts_list), new PrimaryDrawerItem().withName(R.string.sample_realm_list).withDescription(R.string.sample_realm_list_descr).withSelectable(false).withIdentifier(16).withIcon(MaterialDesignIconic.Icon.gmi_format_color_text), new PrimaryDrawerItem().withName(R.string.sample_collapsible_multi_select_delete).withDescription(R.string.sample_collapsible_multi_select_delete_descr).withSelectable(false).withIdentifier(17).withIcon(MaterialDesignIconic.Icon.gmi_check_all), new PrimaryDrawerItem().withName(R.string.sample_sticky_header_mopub).withDescription(R.string.sample_sticky_header_mopub_descr).withSelectable(false).withIdentifier(18).withIcon(MaterialDesignIconic.Icon.gmi_accounts_list), new PrimaryDrawerItem().withName(R.string.sample_diff_util).withDescription(R.string.sample_diff_util_descr).withSelectable(false).withIdentifier(19).withIcon(MaterialDesignIconic.Icon.gmi_refresh), new DividerDrawerItem(), new PrimaryDrawerItem().withName(R.string.open_source).withSelectable(false).withIdentifier(100).withIcon(MaterialDesignIconic.Icon.gmi_github)
.withDrawerWidthRes(R.dimen.dimen_180) .addDrawerItems( new PrimaryDrawerItem().withName("Java").withIcon(DevIcon.Icon.dev_java_plain), new PrimaryDrawerItem().withName("Objective-C").withIcon(DevIcon.Icon.dev_apple_plain), new PrimaryDrawerItem().withName("Swift").withIcon(R.drawable.ic_swift), new PrimaryDrawerItem().withName("JavaScript").withIcon(DevIcon.Icon.dev_javascript_plain), new PrimaryDrawerItem().withName("Python").withIcon(DevIcon.Icon.dev_python_plain), new PrimaryDrawerItem().withName("HTML").withIcon(DevIcon.Icon.dev_html5_plain), new PrimaryDrawerItem().withName("C#").withIcon(DevIcon.Icon.dev_csharp_plain_wordmark), new PrimaryDrawerItem().withName("C++").withIcon(DevIcon.Icon.dev_cplusplus_plain_wordmark), new PrimaryDrawerItem().withName("Ruby").withIcon(DevIcon.Icon.dev_ruby_plain)
public void setUserFolders(@Nullable List<Folder> folders) { clearUserFolders(); if (folders == null) { return; } long openedFolderDrawerId = -1; for (int i = folders.size() - 1; i >= 0; i--) { Folder folder = folders.get(i); long drawerId = folder.getId() << DRAWER_FOLDER_SHIFT; drawer.addItemAtPosition(new PrimaryDrawerItem() .withIcon(getFolderIcon(folder)) .withIdentifier(drawerId) .withTag(folder) .withName(getFolderDisplayName(folder)), headerItemCount); userFolderDrawerIds.add(drawerId); if (folder.getServerId().equals(openedFolderServerId)) { openedFolderDrawerId = drawerId; } } if (openedFolderDrawerId != -1) { drawer.setSelection(openedFolderDrawerId, false); } }
.withFullscreen(true) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1), new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye)
.withToolbar(toolbar) .addDrawerItems( new PrimaryDrawerItem().withName("Home"), new PrimaryDrawerItem().withName(R.string.action_manifestactivity).withIdentifier(R.id.action_manifestactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_extendactivity).withIdentifier(R.id.action_extendactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_customsortactivity).withIdentifier(R.id.action_customsortactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_opensource).withIdentifier(R.id.action_opensource).withSelectable(false)