I have a navigation menu drawer that is set up with multiple groups and menus like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Participant">
<menu>
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_new"
android:icon="@drawable/ic_menu_share"
android:title="@string/nav_new" />
<item
android:id="@+id/nav_start"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/nav_start" />
<item
android:id="@+id/nav_delete"
android:icon="@drawable/ic_menu_manage"
android:title="@string/nav_delete" />
</group>
</menu>
</item>
<item android:title="Sensors">
<menu>
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_raw"
android:icon="@drawable/ic_menu_send"
android:title="@string/nav_raw" />
<item
android:id="@+id/nav_graphs"
android:icon="@drawable/ic_menu_gallery"
android:title="@string/nav_graphs" />
</group>
</menu>
</item>
</menu>
I'm trying to set one of the submenu items to invisible. Lets say I want to hide the Start item. I have tried doing that with:
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
Menu navMenu = navigationView.getMenu();
navMenu.getItem(1).setVisible(false);
I expected it to hide the second item (Start) but instead it just hides the entire second menu group.
Whats the correct way to get a sub item like this? Or am I just incorrectly laying out my menu xml?