Refresh fragment in a view pager within another fragment RRS feed

  • Question

  • User369779 posted

    I have checked several questions here about updating fragments in a ViewPager but none are within another fragment. Still I tried the solutions both in the main fragment and the internal ones and none worked.

    I'm using Xamarin Android and I have an activity with a BottomNavigationView to switch between 5 different Fragments.

    On my first fragment I have a ViewPager with 4 tabs (so 4 fragments). Each of these internal fragments has a ListView.

    When the page loads it all works, fragment appears with the ViewPager and the populated list. I switch between the pages and all the lists are there and fine.

    If I switch to another fragment using the Bottom Navigation and come back then I see the ViewPager meaning I see the tabs but the Listview in the first internal fragment is gone/empty. I switch to the second tab, usually it'll be empty too but if I switch to the 3rd then that one is usually populated and the 4th too and if I switch back to 2 and then 1 they usually get populated.

    How can I refresh the internal fragment/Listview when switching between the external fragments/Bottom Navigation?

    Monday, September 24, 2018 2:51 PM


  • User369779 posted

    I fixed this by changing:

    InternalPagerAdapter adapter = new InternalPagerAdapter(this.FragmentManager);

    to InternalPagerAdapter adapter = new InternalPagerAdapter(this.ChildFragmentManager);

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, September 24, 2018 4:31 PM