Search code examples
androidandroid-tabsviewpage

Clearing OffscreenPage in Android ViewPager


I have a ViewPager and multiple tabs. One of these tabs controls the settings, which affects every other tabs. Everything updates itself perfectly fine when I change the settings, except for the pages that are kept in memory. In order to get these to update I have to select a tab far enough from it, then come back.

Is there a way to force these tabs to recreate themselves?

Thank you


Solution

  • According to this question on SO, you can reset the adapter which will reload all the pages:

    viewPage.setAdapter( adapter );
    

    The duplicate that that question is linked to also gives some helpful information, such as calling .notifyDataSetChanged() on your ViewPager adapter.