且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

底部导航视图:启动应用程序时更改默认突出显示的选项卡

更新时间:2023-01-28 22:21:22

尝试使用您的BottomNavigationViewsetSelectedItemId()方法,如下所示

try this use setSelectedItemId() method of your BottomNavigationView like this

BottomNavigationView bottomNavigationView;
bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottomNavigationView);
bottomNavigationView.setSelectedItemId(R.id.home_menu);

或像这样使用您的视图寻呼机的viewPager.setCurrentItem();

or use viewPager.setCurrentItem(); of your view pager like this

viewPager.setCurrentItem(2);