1

I am using the following method of flipping images: How to set dymanic images to ViewFlipper in android?

I do not want to flip using buttons. When the user touches the images or swipes the image I want to flip to the next image. Is there a way I can achieve this?

Community
  • 1
  • 1
Prens
  • 420
  • 1
  • 5
  • 15

2 Answers2

2

You can use ViewPager. See these links:

Implementing Horizontal View Swiping Using ViewPager and FragmentPagerAdapter in Android

Horizontal View Swiping with ViewPager, Updated

Android Viewpager as Image Slide Gallery (Swipe Gallery)

and this Library

Support Library

AwadKab
  • 3,054
  • 2
  • 17
  • 17
  • 1
    Thanks I used viewpager.. Much better and made my life a lot easier.. I just do not know why I was wasting my time with viewFlipper. To anyone who needs to slide multiple images save ur time and use View Pager.. ! – Prens Apr 02 '13 at 18:06
0

this might Help..... animator is a folder in res and the s_out_* is an xml file with a translate

public boolean onTouchEvent(MotionEvent touchevent) {

    switch (touchevent.getAction()) {
    case MotionEvent.ACTION_DOWN: {
        lastX = touchevent.getX();
        break;
    }
    case MotionEvent.ACTION_UP: {
        float currentX = touchevent.getX();

        if (lastX < currentX) {
            if (viewFlipper.getDisplayedChild() == 0)
                break;

            viewFlipper.setInAnimation(this, R.animator.s_in_fleft);
            viewFlipper.setOutAnimation(this, R.animator.s_out_right);
            viewFlipper.showNext();
        }

        if (lastX > currentX) {
            if (viewFlipper.getDisplayedChild() == 1)
                break;

            viewFlipper.setInAnimation(this, R.animator.s_in_fright);
            viewFlipper.setOutAnimation(this, R.animator.s_out_left);
            viewFlipper.showPrevious();
        }
        break;
    }
}
    return false;

}

oORiggsOo
  • 3
  • 2