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
Here you can use three different groups top , center and bottom. And first top group will have 3 menu items as you have . Then the center group can be same as your "Settings" menu with 2 items. And bottom group will have 2 items as it is in General.
And in your java file you can handle Item Selected Listener to handle the item click of the navigation menu.
// This method will trigger on item Click of navigation menu
@Override
public boolean onNavigationItemSelected(MenuItem p_menuItem) {
//Checking if the item is in checked state or not, if not make it in checked state
if(p_menuItem.getGroupId()==R.id.menu_top){
m_navigationView.getMenu().setGroupCheckable(R.id.menu_bottom,false,true);
m_navigationView.getMenu().setGroupCheckable(R.id.menu_center,false,true);
m_navigationView.getMenu().setGroupCheckable(R.id.menu_top,true,true);
}
else if(p_menuItem.getGroupId()==R.id.menu_center){
m_navigationView.getMenu().setGroupCheckable(R.id.menu_bottom,false,true);
m_navigationView.getMenu().setGroupCheckable(R.id.menu_center,true,true);
m_navigationView.getMenu().setGroupCheckable(R.id.menu_top,false,true);
}
else{
m_navigationView.getMenu().setGroupCheckable(R.id.menu_bottom,true,true);
m_navigationView.getMenu().setGroupCheckable(R.id.menu_center,false,true);
m_navigationView.getMenu().setGroupCheckable(R.id.menu_top,false,true);
}
p_menuItem.setChecked(true);
m_drawerLayout.closeDrawers();