Search code examples
javaandroidsliderphotos

How to implement in android slider of images?


Good evening, dear friends. How to implement the ability to switch (to back and to next photo) of the image by moving it to the edge of the screen (as in popular applications and social networks) and need go to a new activity, if click to photo.

The classes themselves to switch the image I have, as well as the inside my linearlayout in which i have the ImageView, which changes the image, but I can not find the appropriate action handler. I found a few, but there is the image does not move, but simply need to swipe your finger EXACTLY, only handlers react. (OnClick it does not work, and I need to go to a new Activity)

These handlers:

next and previous image by swipe s

Android: How to handle right to left swipe gestures

I hope to get help skilled people. Beforehand, once again many thanks for your help.


Solution

  • Take a look at ViewPager and PagerAdapter. See this tutorial for a ViewPager-based slideshow. If you want to implement it yourself don't use onClick but onTouch listener like demonstrated in this SO answer.