Well, i liked an idea of NavigationView, but had bad experience with programmatically adding menu items & submenus
protected void inflateMenu(Menu menu){
menu.addSubMenu(1, 2, 0, "Heading");
menu.add(MAIN_GROUP_ID, 0, 0, "Something 2");
menu.add(MAIN_GROUP_ID, 1, 0, "Title");
menu.addSubMenu(1, 2, 0, "Sub Menu");
menu.add(1, 3, 0, "Menu #1");
}
Sub menus isn't appearing on NavigationView, but if i remain just adding sub menus without any items, they appeared on the screen, so hence the question, how to solve this?
This was fixed in v23.0.0 of the support library so don't forget to remove the workarounds as soon as you update.
I ran into a similar problem and solved it as follows: You can notify the NavigationView that the data has changed by removing one item.
First adding an item and then deleting it afterwards does the trick for me. Call the following line after you added the Menu:
mNavigationView.getMenu().removeItem(mNavigationView.getMenu().add("").getItemId());
It's not nice but solves the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With