6

I am using NavigationView from the support library. I have a BaseActivity that Activity A and B extend from.

By default app starts with Activity A. When user clicks on a a drawer menu item, i start activity B.

After starting activity B. how can i set the menu item corresponding with it to be highlighted as checked?

Thanks in advance

UPDATE:

Now with the latest update to the support library, you can do:

mDrawer.setCheckedItem(R.id.drawer_profile);
TareK Khoury
  • 12,721
  • 16
  • 55
  • 78

1 Answers1

16

Use the code below:

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

Call this method after you call setNavDrawer();

The getItem(int index) method gets the MenuItem then you can call the setChecked(true); on that MenuItem, all you left to do and find out is which element index does the home the default have, and replace the 0 with that index.

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
Arlind Hajredinaj
  • 8,380
  • 3
  • 30
  • 45