Android Navigation Drawer Remains Highlighted
I have found that simply return false, at the end of onNavigationItemSelected, if you have no need to use the highlight feature.
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return false;
}
To uncheck the item click, you must pass false
on checked item:
public boolean onNavigationItemSelected(MenuItem Item) //will consider to keep this in lower case - item
{
int id = item.getItemId();
if(id == R.id.activity2)
{
Intent goPage2 = new Intent(activity1.this, activity2.class);
startActivity(goPage2);
Item.setChecked(false); //pass false to uncheck
}
}