Set initially selected item index/id in BottomNavigationView

UneXp picture UneXp · Oct 25, 2016 · Viewed 39.3k times · Source

I have implemented BottomNavigationView and have no idea how to set selection index or MenuItem id (in my case, middle item should be selected by default).

I'm afraid there's no such possibility for now as far as it's too raw yet, but anyways any help will be appreciated. Thanks!

Answer

user5968678 picture user5968678 · Apr 7, 2017

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.