在ViewPager的适配器PagerAdapter里边添加如下代码
private int mChildCount = 0;
@Override
public void notifyDataSetChanged() {
mChildCount = getCount();
super.notifyDataSetChanged();
}
@Override
public int getItemPosition(Object object) {
if (mChildCount > 0) {
mChildCount--;
return POSITION_NONE;
}
return super.getItemPosition(object);
}
可以实现ViewPager的notifyDataSetChanged事件,实现ViewPager的更新效果

本文介绍了一种通过重写PagerAdapter的方法来实现ViewPager更新效果的技术方案。主要通过覆盖getItemPosition方法并结合notifyDataSetChanged来达到刷新ViewPager的目的。
842

被折叠的 条评论
为什么被折叠?



