androidandroid-fragmentsandroid-viewpagerandroid-imageandroid-bundle

How to slide images with Viewpager in Android?


I want to slide images using Viewpager, and a number of pictures should be used. (like 30) When you swipe the screen, The images must be changed. (So you should use Viewpager.) of course i can do this by using 30 fragments for the images, but that's not what i wanted. i want to use only one fragment.

I've been searching it for a long time and the only thing that i know is, getArguments() and setArguments() would be helpful, but still have no idea how to do it.. Please let me know. *not good at English tho..


Solution

  • Use ViewPager2. Undercover it's contain RecyclerView that allows you to reuse fragments that goes off the screen.