UneXp UneXp - 1 year ago 215
Android Question

Set initially selected item index/id in BottomNavigationView

I've implemented new BottomNavigationView (com.android.support:design:25.0.0) and have no idea how to set selection index or

MenuItem
id (in my case, mid 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 anyway any help will be appreciated. Thanks!

Answer Source

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 have extra methods/properties in future releases.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download