I am trying to add new menu items to a submenu in the new Material Design drawer panel.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
...
<android.support.design.widget.NavigationView
android:id="@+id/main_navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/channel_list_header"
app:menu="@menu/menu_nav" />
</android.support.v4.widget.DrawerLayout>
I do have the @menu/menu_nav setup but now want to add new menu items:
NavigationView mDrawerList = (NavigationView) findViewById(R.id.main_navigation);
Menu menu = mDrawerList.getMenu();
Menu topChannelMenu = menu.addSubMenu("Top Channels");
topChannelMenu.add("Foo");
topChannelMenu.add("Bar");
topChannelMenu.add("Baz");
mDrawerList.invalidate(); // Trying to force a redraw, doesn't help.
The menu items from the @menu/menu_nav file are shown, but the newly added ones aren't. Any ideas how to do that?