-2

I am using the below code to open another fragment from one fragment:

track nextFrag= new track();
login.this.getFragmentManager().beginTransaction()
        .replace(R.id.content_frame, nextFrag, null)
        .addToBackStack(null)
        .commit();

Code works fine ( I can se ethe new fragment loaded) but the drawer keeps on highlighting the old one (as currently selected). How can I open a fragment and at the same time show it as currently selected in the drawer.

Akshay J
  • 5,362
  • 13
  • 68
  • 105
  • 1
    If you use Android Support Library v23 or above, you can use [NavigationView.setCheckedItem(int)](https://developer.android.com/reference/android/support/design/widget/NavigationView.html#setCheckedItem(int)). For more informations, see [this answer](http://stackoverflow.com/a/31233478/3572108) – Bona Fide Oct 19 '16 at 13:30
  • Thanks, post it as answer so that I can mark it as answered. – Akshay J Oct 19 '16 at 13:37
  • No problem. I did it :-) – Bona Fide Oct 19 '16 at 13:39

1 Answers1

0

As mentioned in the comment section: If you use Android Support Library v23 or above, you can use NavigationView.setCheckedItem(int). For more informations, see this answer.

Community
  • 1
  • 1
Bona Fide
  • 714
  • 1
  • 9
  • 33