diff --git a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java index e61df575d94..67271a2763c 100644 --- a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +++ b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java @@ -269,10 +269,11 @@ public void selectTab(final int newIndex) { } private void selectTab(int newIndex, boolean enableSelectionHistory) { - saveTabSelection(newIndex, enableSelectionHistory); - tabsAttacher.onTabSelected(tabs.get(newIndex)); + final int nextIndex = Math.max(0, Math.min(newIndex, tabs.size() - 1)); + saveTabSelection(nextIndex, enableSelectionHistory); + tabsAttacher.onTabSelected(tabs.get(nextIndex)); getCurrentView().setVisibility(View.INVISIBLE); - bottomTabs.setCurrentItem(newIndex, false); + bottomTabs.setCurrentItem(nextIndex, false); getCurrentView().setVisibility(View.VISIBLE); getCurrentChild().onViewWillAppear(); getCurrentChild().onViewDidAppear();