0

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.

Supriya Pandey
  • 109
  • 1
  • 11

2 Answers2

0

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));

and where to call and item index solution you can refer this link.. this will solve your all problem.

Navigation drawer: How do I set the selected item at startup?

if its not then copy your code so i can tell you how to use this code.

Community
  • 1
  • 1
Sagar Chavada
  • 5,169
  • 7
  • 40
  • 67
0

Maybe you need to use function:

ListView.setItemChecked(int position, boolean checked);

or

ListView.post(new Runnable() {
   @Override
    public void run() {
       ListView.setSelection(index);
    }
});
Sathish Kumar J
  • 4,280
  • 1
  • 20
  • 48
  • can you at least read the question properly, because you are confusing newbie developers.. i know your approach is also right in some cases.. but dont do this. – Sagar Chavada Jul 11 '16 at 10:57