Set selected item in Android BottomNavigationView

前端 未结 21 2380
谎友^
谎友^ 2020-11-27 14:16

I am using the new android.support.design.widget.BottomNavigationView from the support library. How can I set the current selection from code? I realized, that

21条回答
  •  被撕碎了的回忆
    2020-11-27 14:51

    To programmatically click on the BottomNavigationBar item you need use:

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

    This arranges all the items with their labels correctly.

提交回复
热议问题