I need to make a slider which could possibly contain a YouTube video, an image, and a gif.
I can make a slider of an image or a gif, but how can I merge them all in single ViewPager. Please help. Any suggestions or links would be helpful.
I need to make a slider which could possibly contain a YouTube video, an image, and a gif.
I can make a slider of an image or a gif, but how can I merge them all in single ViewPager. Please help. Any suggestions or links would be helpful.
Copyright © 2021 Jogjafile Inc.
Let's suppose that your fragments will be in fixed positions in your ViewPager.. You should make two Fragments with two different layouts let's call them:
ImageFragmentandVideoFragment. you should also extendFragmentPagerAdapterand implementgetItem(int position)like this:EDIT: So this time we'll suppose that you have many images and one video at the end of the ViewPager.. so you can put the paths of images in
ArrayList<String>(maybe local paths or remote paths from server), and put video path in a String variable as well.. and pass each of these strings to the appropriate fragments like this:and you should load each image in the fragment like this:
and VideoFragment will be just as similar to ImageFragment