ViewPager does not redraw content, remains/turns blank

前端 未结 13 903
萌比男神i
萌比男神i 2020-12-12 11:33

We\'re suffering from a very strange issue with ViewPager here. We embed lists on each ViewPager page, and trigger notifyDataSetChanged both on the list adapter and the view

13条回答
  •  伪装坚强ぢ
    2020-12-12 11:56

    ViewPager tries to do clever stuff around re-using items, but it requires you to return new item positions when things have changed. Try adding this to your PagerAdapter:

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

    It basically tells ViewPager that everything has changed (and forces it to re-instantiate everything). That's the only thing I can think of off the top of my head.

提交回复
热议问题