SmoothBottomBar
SmoothBottomBar copied to clipboard
setSelectedItem?
Hello, I'm developing an app which contains Smooth Bottom Bar. I'd like to keep the selected item when the app re-opens. For that I save the selected item in shared preferences and re-use it on re-open. I replace the fragment I want, but the bottom bar doesn't have any function to select the item or to 'fakeclick' programmatically. Thanks in advance, -afsc.
Have you tried setActiveIndex
?
bottomBar.itemActiveIndex = position worked for me, thanks.
bottomBar.itemActiveIndex = position doesn't change the fragment .
Menu menuBottom ;
bottomNavigationView.setItemActiveIndex(3);
NavigationUI.onNavDestinationSelected(menuBottom.getItem(3), navController);
private void setupSmoothBottomBar() {
PopupMenu popupMenu = new PopupMenu(this, null);
popupMenu.inflate(R.menu.menu_bottom);
menuBottom = popupMenu.getMenu();
bottomNavigationView.setupWithNavController(menuBottom, navController);
}