How to display images from SD card in a GalleryView
Posted
by OceanBlue
on Stack Overflow
See other posts from Stack Overflow
or by OceanBlue
Published on 2010-05-25T00:53:40Z
Indexed on
2010/05/25
1:01 UTC
Read the original article
Hit count: 411
android
I am trying to display all the images stored in SD card in a Gallery View.
I have tried using the content provider (android.provider.MediaStore.images.Media class), but seem to be getting stuck at a point. Not sure if this is the way to go about it.
Here is my code so far:
String[] colsNeeded = new String[]{Media._ID, Media.TITLE};
Uri mMedia = Media.EXTERNAL_CONTENT_URI;
//Create a cursor using the URI & column names needd
Cursor c = managedQuery(mMedia, colsNeeded, null, null, Media.DATE_TAKEN + " ASC");
//What kind of adapter should I create here
//that contains images from the cursor??
SpinnerAdapter sa = null; //This is the point I get stuck
//Set the adapter of the gallery view
Gallery galleryPetPhotos = (Gallery)findViewById(R.id.GalleryPetPhotos);
galleryPetPhotos.setAdapter(sa);
Just a nudge in the right direction would be greatly appreciated.
© Stack Overflow or respective owner