I try to implement a drawer with new component of material design : NavigationView.
It's work very well. When I select an item changes its color change well with android:checkableBehavior="single"
.
<group
android:checkableBehavior="single">
<item
android:id="@+id/drawer_home"
android:checked="true"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/home"/>
<item
android:id="@+id/drawer_favourite"
android:icon="@drawable/ic_favorite_black_24dp"
android:title="@string/favourite"/>
...
<item
android:id="@+id/drawer_settings"
android:icon="@drawable/ic_settings_black_24dp"
android:title="@string/settings"/>
</group>
The problem come when I try to use section in drawer. It's this case, I can't use android:checkableBehavior="single"
and I lost the color change in the selection of an item.
<item
android:id="@+id/section"
android:title="@string/section_title">
<menu>
<item
android:id="@+id/drawer_favourite"
android:icon="@drawable/ic_favorite_black_24dp"
android:title="@string/favourite"/>
<item
android:id="@+id/drawer_downloaded"
android:icon="@drawable/ic_file_download_black_24dp"
android:title="@string/downloaded"/>
</menu>
</item>
As a workaround until the bug reported by Fondesa is fixed you can use this:
Menu Definition
Styling
This will properly highly the menu item when selected.
Note that this will not address the requirement:
You will have to handle that manually.
try this:
you can check this solution for details.. I am unable to set a submenu item as checked