I recently started converting an Android app to use the latest support library called support: design.
When introducing a new navigation element, I came across a problem with displaying selected menu items.
My navdrawer_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/navigation_item_home" android:icon="@drawable/ic_home_black" android:title="@string/navdrawer_item_home" /> </group> <item android:id="@+id/navigation_subheader" android:title="@string/navdrawer_subheader_title1"> <menu> <group android:checkableBehavior="single"> <item android:id="@+id/navigation_sub_item1" android:icon="@drawable/ic_home_black" android:title="@string/navdrawer_sub_item1" /> </group> </menu> </item> </menu>
Then I set the menu item to check in my onNavigationItemSelected:
@Override public boolean onNavigationItemSelected(final MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawer(GravityCompat.START); mDrawerActionHandler.postDelayed(new Runnable() { @Override public void run() { displayView(menuItem.getItemId()); } }, DRAWER_CLOSE_DELAY_MS); return true; }
This works fine if I use only the normal menu items between tags, but it does not work very well for subtitles. Clicking on sub-items will not check them until I double-click the same item and it unchecks the previous item.
It looks like this:

source share