1

I am using Navigation Drawer in my Android app, on that showing different MenuItems.

I want to add menuItem dynamically. For that menuItem, I want to set Icon and Title dynamically. I want to set ImageUrl from server in Icon.

Bellow is the code I tried.

Menu menu = mNavigationView.getMenu();
MenuItem item = menu.add(groupId, menuItemId, Order, "Menu Item 1 Title");
item.setIcon(R.drawable.ic_some_menu_item_icon);

But it is not working, kindly help me on this.

Amol Chakane
  • 1,501
  • 2
  • 21
  • 43
Snehangshu Kar
  • 445
  • 2
  • 13
  • Possible duplicate of [dynamic adding item to NavigationView in Android](https://stackoverflow.com/questions/31722566/dynamic-adding-item-to-navigationview-in-android) – Kapta Oct 10 '18 at 19:59
  • Are you actually typing the word `Order`? It won't work then, you need to put an integer there. Replace `Order` with `0` and it works for me. Also, check your `groupId` and `menuItemId`. – Timothy Langer Apr 02 '19 at 12:30

0 Answers0