Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
origin005x opened this issue Oct 28, 2014 · 2 comments

Comments

@origin005x
Copy link

  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
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants