androidandroid-design-libraryandroiddesignsupportselectedindexbottomnavigationview

Set initially selected item index/id in BottomNavigationView


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!


Solution

  • 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.