I have a pager with 5 images with drawing, the image should be scrolled 1-2-3-4-5-1-2-3 in this manner(Circular). I also have the viewpager.i indicator applicable to the code onPageScrollStateChanged(), but it is not broken in the last image. and viewing pagerindicator- termination of work, applied the code.
@Override
public void onPageScrollStateChanged(int state) {
int currentPage = mPager.getCurrentItem();
Log.d("currentpage","currentpage"+currentPage );
if(currentPage==3) {
mPager.setCurrentItem(0);
}
if (state == ViewPager.SCROLL_STATE_IDLE) {
final int lastPosition = mPager.getAdapter().getCount() - 1;
if (currentPage== lastPosition) {
mPager.setCurrentItem(1, false);
} else if (currentPage == 0) {
mPager.setCurrentItem(lastPosition -1, false);
}
}
}
});
I do not want to use a third-party library library.
source
share