1

I'm new in android programming and sorry for my poor english In my android app there is a bottom navigation with 5 items They work great but i have a problem with back button Imagine item 2 is showing its fragment and when user press back button item 1 fragment's is shows but in bottom navigation item 2 seems to be running How could i fix this bug? Thanks

mahdi navidi
  • 123
  • 1
  • 11
  • This could help you!! https://stackoverflow.com/questions/43246059/how-to-set-selected-item-in-bottomnavigationview – Anu Bhalla Jan 29 '19 at 05:07

2 Answers2

0

There are 2 ways:

  • You could handle the onBackPressed on the activity then set the current page for bottomnavigationview
  • Check the current page of the viewpager then set current item for the bottomnavigationview
shizhen
  • 12,251
  • 9
  • 52
  • 88
Henry Hieu
  • 19
  • 2
0

You can do like this
mBottomNavigationView.getMenu().getItem(0).setChecked(true);

here getItem(0) will be count of bottom navigation view item