1

Is there a simple way to manually switch between items of a BottomNavigationView?

I couldn't find any relevant method in the source code.

2hamed
  • 8,719
  • 13
  • 69
  • 112
  • 1
    Nope, not yet. It's been noted, though. http://code.google.com/p/android/issues/detail?id=225900 http://code.google.com/p/android/issues/detail?id=227851 – Mike M. Nov 19 '16 at 12:55

2 Answers2

2

Ok, I found a temporary workaround for this until an official update addresses this issue.

((BottomNavigationMenuView) bottomNav.getChildAt(0)).getChildAt(ITEM_INDEX).callOnClick();
2hamed
  • 8,719
  • 13
  • 69
  • 112
0

A safer alternative to Hamed's solution would be the following:

bottomNav.setSelectedItemId(bottomNav.getMenu().getItem(ITEM_INDEX).getItemId());
Christian Brüggemann
  • 2,152
  • 17
  • 23