Android ViewFlipper back to first view
Asked Answered
S

2

5

My viewFlipper contains 15 LinearLayout. After it reaches, I have a button "Back to menu".

I've used

showNext()

all the way to the 15th LinearLayout. And now I want it to go back to 1st LinearLayout. Anyone have any idea? How to bring it back to 1st Linearlayout?

Thanks.

Sedberry answered 5/3, 2011 at 20:40 Comment(0)
F
28

Call showNext(). Or, call setDisplayedChild(0).

Fulmer answered 5/3, 2011 at 20:44 Comment(1)
what if i want to diplay every activity in between ??with slide in and slide out animation?Embed
T
0

I used this code.

private ViewFlipper vf;
private float lastX;


case MotionEvent.ACTION_UP: {
float currentX = touchevent.getX();
    if (lastX < currentX) {
        vf.setInAnimation(this, R.anim.in_from_left);
        vf.setOutAnimation(this, R.anim.out_to_right);
        vf.showNext();
        }
if (lastX > currentX) {
            vf.setInAnimation(this, R.anim.in_from_right);
            vf.setOutAnimation(this, R.anim.out_to_left);
            vf.showPrevious();
            }
break;
}
Territoriality answered 10/6, 2014 at 22:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.