2

I have images on the SD card and I want to show these images in an Activity with a ViewPager.

On horizontal scroll the image should change.

Chilledrat
  • 2,593
  • 3
  • 28
  • 38
Kalu Khan Luhar
  • 1,044
  • 1
  • 22
  • 35

2 Answers2

3

With this methode you can retrive your picture from SDcard in a drwable object

public Drawable getImageFromSdCard(String imageName) {
    Drawable d = null;
    try {
        String path = Environment.getExternalStorageDirectory().toString()
                + "/YourSubDirectory/";
        Bitmap bitmap = BitmapFactory.decodeFile(path + "/" + imageName
                + ".png");
        d = new BitmapDrawable(bitmap);
    } catch (IllegalArgumentException e) {
        // TODO: handle exception
    }
    return d;

}

and then just call this Drawable in your ViewPager.

G.Luck

Wajdi Hh
  • 785
  • 3
  • 9
  • @WasimAkram I am looking for same, quite new to android. How can I call this in myviewpager. I am successfully retrieving images from drawable folder, but unable to get images from SD card. – MajorGeek Jun 09 '13 at 16:58
1

use this: Retrieving only images from gallery when firing android image chooser intent to get image from gallery.

And use this to show it horizontally: http://developer.android.com/resources/tutorials/views/hello-gallery.html

You need to club both these codes together.

Community
  • 1
  • 1
Shrikant Ballal
  • 7,067
  • 7
  • 41
  • 61