LoopViewPager icon indicating copy to clipboard operation
LoopViewPager copied to clipboard

How to scroll from last to first by code?

Open yswheye opened this issue 8 years ago • 2 comments

How to scroll from last to first by code

yswheye avatar Feb 20 '17 08:02 yswheye

I have same issue. +1

esperia avatar Jul 14 '17 15:07 esperia

I wrote this code to LoopViewPager.java:

    public void next() {
        if (getCurrentItem() == mAdapter.getCount() - 1) {
            mPopulatePending = true;
            setCurrentItemInternal(0, true, true, -15000); // velocity is hard-coded
            ViewCompat.postInvalidateOnAnimation(this);
        } else {
            setCurrentItem(getCurrentItem() + 1, true);
        }
    }

Call:

mLoopViewPager.next();

It seems working. but the code has not been fully tested.

UPDATED(2017-08-03): I fixed a bug that it working only items <= 3(but it depends on page settings).

esperia avatar Jul 18 '17 15:07 esperia