这里修改的只是样式(就是底部导航栏按钮默认选中第三个,但是页面其实没有设置),下标从0开始,我这里设置的是默认选中第三个按钮
写在MainActivity里
bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottomNavigationView);
bottomNavigationView.getMenu().getItem(2).setChecked(true);
设置第三个fragment默认显示的代码
lastfragment = 2;
getSupportFragmentManager().beginTransaction().replace(R.id.frame_fragment,home_fragment).show(home_fragment).commit();