0
我想加載圖像並以列表的形式顯示爲圖庫。 問題是,我能夠從默認的Android畫廊做到這一點,但我不知道如何做自定義文件夾。例如/圖片文件夾。我一直在嘗試,這裏是我用於默認圖庫的代碼,我希望它用於其他文件夾,例如/圖片/列。從自定義文件夾加載圖片庫
public static List<PhotoItem> getAlbumThumbnails(Context context){
final String[] projection = {MediaStore.Images.Thumbnails.DATA, MediaStore.Images.Thumbnails.IMAGE_ID};
Cursor thumbnailsCursor = context.getContentResolver().query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null, // Return all rows
null,
null);
// Extract the proper column thumbnails
int thumbnailColumnIndex = thumbnailsCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
ArrayList<PhotoItem> result = new ArrayList<PhotoItem>(thumbnailsCursor.getCount());
if (thumbnailsCursor.moveToFirst()) {
do {
// Generate a tiny thumbnail version.
int thumbnailImageID = thumbnailsCursor.getInt(thumbnailColumnIndex);
String thumbnailPath = thumbnailsCursor.getString(thumbnailImageID);
Uri thumbnailUri = Uri.parse(thumbnailPath);
Uri fullImageUri = uriToFullImage(thumbnailsCursor,context);
// Create the list item.
PhotoItem newItem = new PhotoItem(thumbnailUri,fullImageUri);
result.add(newItem);
} while (thumbnailsCursor.moveToNext());
}
thumbnailsCursor.close();
return result;
}
什麼都應該在這裏我改變,我試圖改變投影,查詢參數,但在這一領域的失敗,新的,請幫助:)