castorflex / VerticalViewPager

Copy pasted version of the support ViewPager, but vertical!
1.11k stars 307 forks source link

pageAdapter.notifyDataSetChanged() could not let the VerticalViewPager refresh its layout #15

Closed origin005x closed 9 years ago

origin005x commented 9 years ago
  1. I add some elements to VerticalViewPager.
  2. clear the elements and add some new elements
  3. use pageAdapter.notifyDataSetChanged(). but it doesn't work. why?
origin005x commented 9 years ago

this issue has been resolved. Seems that the VerticalViewPager has nothing wrong. The reason for this is that MyPageAdapter did not rewrite the method 'getItemPosition()' from the super class, and the default implementation assumes that items will never change position and always returns.

So, rewrite this method like this: int index = mdata.indexOf(object); return index == -1 ? POSITION_NONE : index;

Hope useful for others.

CiprianU commented 9 years ago

also, your adapter should extend FragmentStatePagerAdapter (http://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter.html) instead of PagerAdapter.