【问题标题】:how to show selected images in listview?如何在列表视图中显示选定的图像?
【发布时间】:2011-11-10 12:41:20
【问题描述】:

在我的应用中,我可以通过代码访问图库

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);

现在通过startActivityForresult();我可以得到所选图像的URI。我在ArrayList<String> imageList 中添加了 URI,我想通过另一个 Activity 在 ListView 中显示图像。 请帮忙??

【问题讨论】:

  • 请更清楚您的问题。我不明白你的问题。
  • 我想从图库中选择图像并将它们显示到列表视图中。
  • 我现在知道了。您愿意分享您在 ListAdapter 中使用的 getView() 方法代码吗?

标签: android listview listactivity listadapter


【解决方案1】:

我认为您可以将该列表发送给另一个 ActivityListView将其公开以供其他活动访问

Adapter's getView 方法中分配Image to ImageView 时这样做,

Uri contentUri = imageList.get(position);
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String tmppath = cursor.getString(column_index);

Bitmap imaage = BitmapFactory.decodeFile(tmppath);
imageView.setImageBitmap(image);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    • 2013-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多