Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Show the items into the menu.
- @Override
- protected NavDrawerActivityConfiguration getNavDrawerConfiguration() {
- NavDrawerItem[] menu = new NavDrawerItem[] {
- //This sets the name, mine is a multilanguage app so I wanna find a way to use @string/resource instead
- //of "PERFORMANCE", ecc.
- NavMenuItem.create(1,"PERFORMANCE", "", false, this),
- NavMenuItem.create(2, "MALI", "", false, this),
- NavMenuItem.create(3, "BATTERY", "", false, this),
- NavMenuItem.create(4, "CPU", "", false, this),
- NavMenuItem.create(5, "MISC", "", false, this),
- NavMenuItem.create(6, "NET", "", false, this),
- NavMenuItem.create(7, "HELP", "", false, this),
- NavMenuItem.create(8, "GUIDE", "", false, this)};
- NavDrawerActivityConfiguration navDrawerActivityConfiguration = new NavDrawerActivityConfiguration();
- navDrawerActivityConfiguration.setMainLayout(R.layout.main);
- navDrawerActivityConfiguration.setDrawerLayoutId(R.id.drawer_layout);
- navDrawerActivityConfiguration.setLeftDrawerId(R.id.left_drawer);
- navDrawerActivityConfiguration.setNavItems(menu);
- navDrawerActivityConfiguration.setDrawerShadow(R.drawable.drawer_shadow);
- navDrawerActivityConfiguration.setDrawerOpenDesc(R.string.drawer_open);
- navDrawerActivityConfiguration.setDrawerCloseDesc(R.string.drawer_close);
- navDrawerActivityConfiguration.setBaseAdapter(
- new NavDrawerAdapter(this, R.layout.navdrawer_item, menu ));
- return navDrawerActivityConfiguration;
- }
- public class NavMenuItem implements NavDrawerItem {
- public static final int ITEM_TYPE = 1 ;
- private int id ;
- private String label ;
- private boolean updateActionBarTitle ;
- private NavMenuItem() {
- }
- public static NavMenuItem create( int id, String label, String icon, boolean updateActionBarTitle, Context context ) {
- NavMenuItem item = new NavMenuItem();
- item.setId(id);
- item.setLabel(label);
- item.setUpdateActionBarTitle(updateActionBarTitle);
- return item;
- }
- @Override
- public int getType() {
- return ITEM_TYPE;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getLabel() {
- return label;
- }
- public void setLabel(String label) {
- this.label = label;
- }
- @Override
- public boolean isEnabled() {
- return true;
- }
- @Override
- public boolean updateActionBarTitle() {
- return this.updateActionBarTitle;
- }
- public void setUpdateActionBarTitle(boolean updateActionBarTitle) {
- this.updateActionBarTitle = updateActionBarTitle;
- }
- public interface NavDrawerItem {
- public int getId();
- public String getLabel();
- public int getType();
- public boolean isEnabled();
- public boolean updateActionBarTitle();
- getString(R.string.name);
- context.getResources().getString(R.string.name);
- NavDrawerItem[] menu = new NavDrawerItem[] {
- //This sets the name, mine is a multilanguage app so I wanna find a way to use @string/resource instead
- //of "PERFORMANCE", ecc.
- NavMenuItem.create(1,getString(R.string.performance_name), "", false, this)
- ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement