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.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
Muazam
  • 379
  • 1
  • 6
  • 15

2 Answers2

28

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

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
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;
}
Boris Karloff
  • 1,190
  • 12
  • 20