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
Asked
Active
Viewed 320 times
1
-
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 Answers
0
There are 2 ways:
- You could handle the
onBackPressed
on the activity then set the current page forbottomnavigationview
- Check the current page of the
viewpager
then set current item for thebottomnavigationview

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

Krutika Chotara
- 143
- 11