Android ViewFlipper at a glance

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

I used

showNext() 

until the 15th LinearLayout. And now I want him to return to 1 LinearLayout. Does anyone have an idea? How to return it before the 1st Linringayout?

Thanks.

+4
source share
2 answers

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

+23
source

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; } 
0
source

Source: https://habr.com/ru/post/1342449/


All Articles