Search code examples
androidnativescript

Nativescript setting selectedIndex on BottomNavigation not working on Android


I'm trying to programmatically set the selectedIndex of my bottom-navigation.

It works on iOS - but on Android, nothing happens.

const rootView = Application.getRootView();
    const bottomBar = rootView.getViewById("bottomNavigation");
console.log('bottomBar', bottomBar.selectedIndex);
    bottomBar.selectedIndex = 2;
    console.log('bottomBar-changed', bottomBar.selectedIndex);

The console.log shows that the selectedIndex actually changed.

I tried rootView.requestLayout() to refresh the view, but that didn't help.

Any ideas?

Nativescript 8.x, BottomBar from plugin (@nativescript-community/ui-material-bottom-navigation)


Solution

  • Seems like it was a bug in 5.2.15 - updated to 5.2.17 and now it's working.