458_无限滚动的ViewPager
2017-01-05 21:48
351 查看
无限滚动的ViewPager
list = new ArrayList<>();
list.add(new NumberFragment(4));
list.add(new NumberFragment(1));
list.add(new NumberFragment(2));
list.add(new NumberFragment(3));
list.add(new NumberFragment(4));
list.add(new NumberFragment(1));
vp_content.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
private int currentPosition;
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE) {
if (currentPosition == vp_content.getAdapter().getCount() - 1) {
vp_content.setCurrentItem(1, false);
} else if (currentPosition == 0) {
vp_content.setCurrentItem(vp_content.getAdapter().getCount() - 2, false);
}
}
}
@Override
public void onPageScrolled(int scrolledPosition, float percent, int pixels) {
}
@Override
public void onPageSelected(int position) {
currentPosition = position;
}
});
list = new ArrayList<>();
list.add(new NumberFragment(4));
list.add(new NumberFragment(1));
list.add(new NumberFragment(2));
list.add(new NumberFragment(3));
list.add(new NumberFragment(4));
list.add(new NumberFragment(1));
vp_content.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
private int currentPosition;
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE) {
if (currentPosition == vp_content.getAdapter().getCount() - 1) {
vp_content.setCurrentItem(1, false);
} else if (currentPosition == 0) {
vp_content.setCurrentItem(vp_content.getAdapter().getCount() - 2, false);
}
}
}
@Override
public void onPageScrolled(int scrolledPosition, float percent, int pixels) {
}
@Override
public void onPageSelected(int position) {
currentPosition = position;
}
});
相关文章推荐
- ViewPager:真正实现图片的无限轮播、自定义指示点和条目点击事件(支持长按暂停滚动)
- ViewPager的使用和无限滚动的实现
- android简单实现无限滚动,自动滚动的ViewPager
- Android ViewPager无限循环滑动并可自动滚动完整实例
- 记android ViewPager实现轮播图的无限滚动笔记
- viewpager无限自动滚动
- viewpager实现无限循环滚动幻灯片
- android viewpager实现无限循环自动滚动
- viewpager无限循环滚动遇到的坑
- Android简单实现无限滚动自动滚动的ViewPager
- 【Android】ViewPager实现无限循环滚动
- 无限滚动的viewpager 高级ViewPager_Devlight/InfiniteCycleViewPager
- Android 一个无限循环滚动的卡片式ViewPager
- android ViewPager无限滚动、轮播图
- autoscrollviewpager + indicator 无限滚动
- android自定义控件-AutoScrollViewpager(无限滚动轮播控件)
- Android ViewPager的无限循环与自动滚动实现
- ViewPager 无限滚动广告栏
- ViewPager设置广告位,无限滚动
- Android中ViewPager支持一屏多个View、切换动画以及无限滚动