Search code examples
androidandroid-fragmentsandroid-activitybottomnavigationview

onNavigationItemSelected is not called when the selected menu item is same


I have a simple BottomNavigationView with two menu items (Home Fragment, Settings Fragment) in an activity.

I have implemented onNavigationItemSelectedListener and onNavigationItemSelected.

Also bottomNavigationView.setOnNavigationItemSelectedListener(this);

App page lands on the Home Fragment.

onNavigationItemSelected is being called when I switch between menu items but When I first launch the app and tap on the same menu Item i.e. Home Fragment, onNavigationItemSelected is not being called.

I would need to show a toast whenever the user clicks on the home page when user is already in home page but onNavigationItemSelected event is not triggered.


Solution

  • As Mike M mentioned,

    setOnNavigationItemReselectedListener did the trick.