Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. //Show the items into the menu.
  2. @Override
  3. protected NavDrawerActivityConfiguration getNavDrawerConfiguration() {
  4.  
  5. NavDrawerItem[] menu = new NavDrawerItem[] {
  6.  
  7. //This sets the name, mine is a multilanguage app so I wanna find a way to use @string/resource instead
  8. //of "PERFORMANCE", ecc.
  9. NavMenuItem.create(1,"PERFORMANCE", "", false, this),
  10. NavMenuItem.create(2, "MALI", "", false, this),
  11. NavMenuItem.create(3, "BATTERY", "", false, this),
  12. NavMenuItem.create(4, "CPU", "", false, this),
  13. NavMenuItem.create(5, "MISC", "", false, this),
  14. NavMenuItem.create(6, "NET", "", false, this),
  15. NavMenuItem.create(7, "HELP", "", false, this),
  16. NavMenuItem.create(8, "GUIDE", "", false, this)};
  17.  
  18. NavDrawerActivityConfiguration navDrawerActivityConfiguration = new NavDrawerActivityConfiguration();
  19. navDrawerActivityConfiguration.setMainLayout(R.layout.main);
  20. navDrawerActivityConfiguration.setDrawerLayoutId(R.id.drawer_layout);
  21. navDrawerActivityConfiguration.setLeftDrawerId(R.id.left_drawer);
  22. navDrawerActivityConfiguration.setNavItems(menu);
  23. navDrawerActivityConfiguration.setDrawerShadow(R.drawable.drawer_shadow);
  24. navDrawerActivityConfiguration.setDrawerOpenDesc(R.string.drawer_open);
  25. navDrawerActivityConfiguration.setDrawerCloseDesc(R.string.drawer_close);
  26. navDrawerActivityConfiguration.setBaseAdapter(
  27. new NavDrawerAdapter(this, R.layout.navdrawer_item, menu ));
  28. return navDrawerActivityConfiguration;
  29. }
  30.  
  31. public class NavMenuItem implements NavDrawerItem {
  32.  
  33. public static final int ITEM_TYPE = 1 ;
  34.  
  35. private int id ;
  36. private String label ;
  37. private boolean updateActionBarTitle ;
  38.  
  39. private NavMenuItem() {
  40. }
  41.  
  42. public static NavMenuItem create( int id, String label, String icon, boolean updateActionBarTitle, Context context ) {
  43. NavMenuItem item = new NavMenuItem();
  44. item.setId(id);
  45. item.setLabel(label);
  46. item.setUpdateActionBarTitle(updateActionBarTitle);
  47. return item;
  48. }
  49.  
  50. @Override
  51. public int getType() {
  52. return ITEM_TYPE;
  53. }
  54.  
  55. public int getId() {
  56. return id;
  57. }
  58.  
  59. public void setId(int id) {
  60. this.id = id;
  61. }
  62.  
  63. public String getLabel() {
  64. return label;
  65. }
  66.  
  67. public void setLabel(String label) {
  68. this.label = label;
  69. }
  70.  
  71.  
  72. @Override
  73. public boolean isEnabled() {
  74. return true;
  75. }
  76.  
  77. @Override
  78. public boolean updateActionBarTitle() {
  79. return this.updateActionBarTitle;
  80. }
  81.  
  82. public void setUpdateActionBarTitle(boolean updateActionBarTitle) {
  83. this.updateActionBarTitle = updateActionBarTitle;
  84. }
  85.  
  86. public interface NavDrawerItem {
  87. public int getId();
  88. public String getLabel();
  89. public int getType();
  90. public boolean isEnabled();
  91. public boolean updateActionBarTitle();
  92.  
  93. getString(R.string.name);
  94.  
  95. context.getResources().getString(R.string.name);
  96.  
  97. NavDrawerItem[] menu = new NavDrawerItem[] {
  98.  
  99. //This sets the name, mine is a multilanguage app so I wanna find a way to use @string/resource instead
  100. //of "PERFORMANCE", ecc.
  101. NavMenuItem.create(1,getString(R.string.performance_name), "", false, this)
  102. ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement