Supriya Pandey Supriya Pandey - 4 months ago 19
Android Question

Navigation Drawer Item ByDefault selected not on click andorid

I am new to android, I am using navigation drawer for displaying my item list.

I faced some issues, Like when i come to my navigation Activity, the list name as Restaurant displayed. This Restaurant item as well included in my drawer item which is similar to other one. First time when I come to Navigation Activity, I want to highlight restaurant item. How Can I do it?

Kindly tell me.

Answer

this is simple one line code:

navigationView.getMenu().getItem(0).setChecked(true);

and You can select(highlight) the item by calling

onNavigationItemSelected(navigationView.getMenu().getItem(0));