Bottom Navigation View : Change the default highlighted Tab when the app launches

旧巷老猫 提交于 2019-12-08 02:48:20

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

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

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

viewPager.setCurrentItem(2);
   /***Just try to use below code snipet***/

   viewPager.setCurrentItem(2);

   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
   {
     home_icon.setImageDrawable(getResources().getDrawable(R.drawable.home_icon_selected_state, getApplicationContext().getTheme()));

   }
   else
   {
     home_icon.setImageDrawable(getResources().getDrawable(R.drawable.home_icon_selected_state));
   }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!