I have a working Navigation Drawer and having some issues with menuItem.setChecked(true);
when using groups and headers within the menu. It's not highlighting menu items as expected.
Here is my XML:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ActivityMap">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_welcome"
android:icon="@drawable/abc_btn_check_to_on_mtrl_000"
android:title="Welcome" />
<item
android:id="@+id/nav_map_showmap"
android:icon="@mipmap/ic_map_black_24dp"
android:title="Show Map" />
<item
android:icon="@mipmap/ic_list_black_24dp"
android:title="Show List" />
<item android:title="Settings">
<menu>
<item
android:id="@+id/nav_database_check"
android:icon="@mipmap/ic_cloud_done_black_24dp"
android:title="Update Database" />
<item
android:id="@+id/nav_map_settings"
android:icon="@mipmap/ic_settings_black_24dp"
android:title="App Preferences" />
</menu>
</item>
<item android:title="General">
<menu>
<item
android:id="@+id/nav_general_about"
android:icon="@mipmap/ic_info_black_24dp"
android:title="About" />
<item
android:id="@+id/nav_general_help"
android:icon="@mipmap/ic_help_black_24dp"
android:title="Help" />
<item
android:id="@+id/nav_general_report"
android:icon="@mipmap/ic_email_black_24dp"
android:title="Feedback / Report error" />
</menu>
</item>
</group>
</menu>
As you can see I have 3 menu items, then a Settings Group with 2 menu items, then a General Group with 3 menu items.
Now with the first 3 menu items, the menuItem.setChecked(true);
is working as expected, and highlighting that menu item. However, none of the following menu items within the subset ("Settings" or "General" subsets) are highlighting correctly.
I read that the <group android:checkableBehaviour="single">
can encapsulate the whole block, but that doesn't seem to be working.
Any thoughts? Cheers.
EDIT - Added Screenshot of the menu structure