2hamed
2hamed

Reputation: 9047

Manually switch Android BottomNavigationView

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

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

Upvotes: 1

Views: 521

Answers (2)

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

bottomNav.setSelectedItemId(bottomNav.getMenu().getItem(ITEM_INDEX).getItemId());

Upvotes: 0

2hamed
2hamed

Reputation: 9047

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

((BottomNavigationMenuView) bottomNav.getChildAt(0)).getChildAt(ITEM_INDEX).callOnClick();

Upvotes: 2

Related Questions