【发布时间】:2011-03-25 07:58:03
【问题描述】:
在我的画廊中,我有 3 个目录。 sahoo 是目录之一。我在所有三个目录中都有不同的图像。但我只想显示 sahoo 目录的图像。我的程序显示了画廊中存在的所有图像。但我只想从 sahoo 目录中获取图像。怎么做? 我用的是安卓。
谢谢 迪帕克
我使用了以下代码
Uri uri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
Cursor mCursor = this.getContentResolver().query(uri, null, selection, null, null);
在 getview 方法中,我编写了以下代码行
mCursor.moveToPosition(position);
Log.e(TAG,"the position is"+position);
long id = mCursor.getLong(mCursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.IMAGE_ID));
// Log.e(TAG,"the value of id= "+id);
//create the Uri for the Image
Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id+"");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);
【问题讨论】:
-
你的 sahoo 目录是画廊的子目录吗?
-
是的,它有效。 sahoo目录是gallery的子目录
标签: android