2

I have 3 types of users Each user has different menu options in navigation drawer.that menu options are getting from the server.I have a single login screen for three users.according to the user login, the menu will be delivered from the server.I want to add that menu item to the navigation drawer.I got some code during the search.but what I want to know, how to design navigation drawer for accept dynamic menu items

   NavigationView navView = (NavigationView) 
   findViewById(R.id.your_nav_view_id);
   Menu m = navView.getMenu();
   SubMenu menuGroup = m.addSubMenu("My menu group");
   menuGroup .add("name");
   menuGroup .add("address");
  • https://stackoverflow.com/questions/17311833/how-we-can-add-menu-item-dynamically – Amit Vaghela Sep 12 '17 at 05:37
  • Check this out https://stackoverflow.com/questions/18412395/using-a-drawerlayout-along-with-a-listview – Ashish Kumar Sep 12 '17 at 05:37
  • Possible duplicate of [how we can add menu item dynamically](https://stackoverflow.com/questions/17311833/how-we-can-add-menu-item-dynamically) – Ank Sep 12 '17 at 05:42

2 Answers2

1

You can add a recycler view in the navigation layout and set an adapter to it and set the data received from the server.

sajad abbasi
  • 1,988
  • 2
  • 22
  • 43
0

Try this snippet:

final Menu menu = navigationView.getMenu();
menu.add("new menu");
noamt
  • 7,397
  • 2
  • 37
  • 59
Jey Arun
  • 103
  • 5