Search code examples
androidnavigationandroid-architecture-navigation

Is there a way to force the navigation component to recreate a fragment when the bottom navigation is reselected


So basically, I have a bottom navigation using the Navigation component for Android. I need to refresh my fragment when reselecting the bottom navigation but when I reselect the item in the bottom nav, it keeps the state of the fragment the same. Is it possible to use the navcontroller to force the fragment to refresh?


Solution

  • You can use a callback and when reselected just call the function again which is fetchingData() and set it to UI.

    Without seeing your code, it's difficult to help you with the exact answer.