How can i load all the images located in one folder into android listview dynamically..?
Asked
Active
Viewed 2,646 times
2
-
Please have a look at : [Android - How do I do a lazy load of images in ListView][1] [1]: http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012 – Sanjay Kumar Dec 27 '11 at 07:24
-
I'm referring this link https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java, they are reading images trough web, but i want to read them from specific folder or from res/drawable – user1065490 Dec 27 '11 at 07:34
1 Answers
0
First Retrieve all images from a specific using the following code.
Second Use LazyList concept to load images. Lazy load of images in ListView
How to get all iamges from a specific folder
public void searchSDCardForImage() {
String path = null;
String uri = MediaStore.Images.Media.DATA;
String condition = uri + " like '%/GetImageFromThisDirectory/%'";
String[] projection = { uri, MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media.SIZE };
Vector additionalFiles = null;
try {
if (additionalFiles == null) {
additionalFiles = new Vector<String>();
}
Cursor cursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,
condition, null, null);
if (cursor != null) {
boolean isDataPresent = cursor.moveToFirst();
if (isDataPresent) {
do {
path = cursor.getString(cursor.getColumnIndex(uri));
System.out.println("...path..."+path);
additionalFiles.add(path);
}while(cursor.moveToNext());
}
if (cursor != null) {
cursor.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

Community
- 1
- 1

Sunil Kumar Sahoo
- 53,011
- 55
- 178
- 243