0

I'm trying to make Loop on image swipe view, this is the source image that I'm using. How can I continue swipe the image after the last one it turns to the beginning one. Thanks

private class ImagePagerAdapter extends PagerAdapter {
private int[] mImages = new int[] {

    R.drawable.image1,
    R.drawable.image2,
    R.drawable.image3,
    R.drawable.image4,

};
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
Adam
  • 7
  • 2
  • This so post will help you start http://stackoverflow.com/questions/11622544/fix-the-animation-of-a-circular-viewpager – Ravi Oct 29 '13 at 11:47

1 Answers1

0

I assume you are using a viewpager?

There are some threads on stackoverflow which explain how to do this. One of those can be found here and I copy/pasted the code that was used there below:

@Override
public void onPageScrollStateChanged (int state) {
    if (state == ViewPager.SCROLL_STATE_IDLE) {
        int curr = viewPager.getCurrentItem();
        int lastReal = viewPager.getAdapter().getCount() - 2;
        if (curr == 0) {
            viewPager.setCurrentItem(lastReal, false);
        } else if (curr > lastReal) {
            viewPager.setCurrentItem(1, false);
        }
    }
}
Community
  • 1
  • 1
rmuller
  • 1,837
  • 12
  • 12