Refresh images on FragmentStatePagerAdapter on resuming activity

前端 未结 4 1219
离开以前
离开以前 2020-12-09 16:47

I have created an activity that uses FragmentStatePagerAdapter to provide small gallery. However, I can\'t get it to refresh when activity resumes (after coming

4条回答
  •  生来不讨喜
    2020-12-09 17:26

    Dealing with fragment pager adapters can be a PITA.

    Here are a few helpful tips:

    ViewPager PagerAdapter not updating the View

    Update ViewPager dynamically?

    Generally speaking this one works 99% of the time...

    Override getItemPosition in your PagerAdapter like this:

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
    

    Sometimes even those don't work, I have to use the 'brute force' method and recreate the entire view again (from onCreate onwards)...

提交回复
热议问题