문제

i'm using RealViewSwitcher I got from this site.

It works perfectly on my code, but I don't have any idea how to set the initial current screen to second or third screen.

the method setCurrentScreen(int) doesn't affect anything and if I change the for loop inside the onLayout() method from for (int i = 0; i < count; i++) {...} into for (int i = 1; i < count; i++){...} It does starts in page two, but you can't go to page one.

Any idea how to start on page two?

도움이 되었습니까?

해결책

The local solution is to add new class method. If you want start on second page - just call snapToScreenFast(2).

public void snapToScreenFast(int whichScreen) {
    if (!mScroller.isFinished())
        return;

    whichScreen = Math.max(0, Math.min(whichScreen, getChildCount() - 1));

    mNextScreen = whichScreen;

    final int newX = whichScreen * getWidth();
    final int delta = newX - getScrollX();
    mScroller.startScroll(getScrollX(), 0, delta, 0, 0);
    invalidate();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top