Set initially selected item index/id in BottomNavigationView Set initially selected item index/id in BottomNavigationView android android

Set initially selected item index/id in BottomNavigationView


Set the selected menu item ID using setSelectedItemId:

bottomNavigationView.setSelectedItemId(R.id.item_id);

This method started being available from Android Support Library 25.3.0.


The only solution that worked for me is:

View view = bottomNavigationView.findViewById(R.id.menu_action_dashboard);view.performClick();

Simply performing click does the trick. Hope we'll get extra methods/properties in future releases.

UPD:

As user5968678 mentioned, a new method was added since Android Support Library v25.3.0:

bottomNavigationView.setSelectedItemId(R.id.item_id);

so use this instead :)


I think this solution my be slightly more elegant than accepted answer:

bottomNavigationView.getMenu().getItem(menuItemIndex).setChecked(true)

where menuItemIndex is index of the selected element.