1

Currenlty I am working in a project where I have to select multiple images from gallery and have to display all selected images as a swipeable view(viewpager indicator). I have gone through many examples but every where I found static images with viewpager. How to show selected images in viewpager with indicator?

I am following this for selecting multiple images https://github.com/luminousman/MultipleImagePick This is how i am selecting images from gallery

Zafar Imam
  • 319
  • 3
  • 11

1 Answers1

1

Use ViewPager with FragmentStatePagerAdapter if you have more data to show or FragmentPagerAdapter.

You can read here about the difference between these two and when to use it.

Difference between FragmentPagerAdapter and FragmentStatePagerAdapter

Use CircularPageIndicator for images indication.

Now coming back to your question, you want to show the selected data or say images, you can pass these images to the viewPager adapter and it will takes care of it.

Read here, about how to use FragmentStatePagerAdapter with ViewPager.

https://guides.codepath.com/android/ViewPager-with-FragmentPagerAdapter

Community
  • 1
  • 1
Ritt
  • 3,181
  • 3
  • 22
  • 51
  • Actually i am looking for setting dynamic images with pager as selected from gallery..In every example which i have gone through they are using static data with viewpager..Currently I am getting multiple images and able to display in grid view but getting difficulty to show in viewpager.. – Zafar Imam Feb 16 '16 at 06:48
  • what difficulty are you facing, you can pass the selected images in the view pager adapter and the adapter will show those images, checkout the last link mentioned in post. – Ritt Feb 16 '16 at 06:56
  • This is how i am getting multiple images `if (requestCode == 200 && resultCode == Activity.RESULT_OK) { String[] all_path = data.getStringArrayExtra("all_path"); ArrayList dataT = new ArrayList(); for (String string : all_path) { CustomGallery item = new CustomGallery(); item.sdcardPath = string; dataT.add(item); } viewSwitcher.setDisplayedChild(0); adapter.addAll(dataT); }` From here how to set images to viewpager ? – Zafar Imam Feb 16 '16 at 07:31
  • I guess, just giving the path will not work. Check out this link, which explains how to get images from sd card. http://stackoverflow.com/questions/16557650/how-to-display-images-saved-in-sdcard-folder-in-android – Ritt Feb 16 '16 at 07:52