0

I am working on an a simple android application that stores objects in an array, and displays them to the user via a listview. Each object contains a photo and a single text field. For demonstration purposes, I would like to pre-populate this array with some hardcoded objects.

The trouble is that the images are typically acquired through the camera interface, and each object only stores the path to that image. I can add the hardcoded images as drawables, but then they don't have a file path. I could when the app is initialized, convert the drawables to bitmaps and save the bitmaps to the SD card, but that seems too complicated to be the correct answer...

Any ideas on the best way to get these images into file storage so that I refer to them via their URIs?

Thanks!

4

2 回答 2

0

当您在适配器中创建视图时,ImageView在您的布局中有一个并使用加载器或自定义AsyncTask在后台加载图像并ImageView让它在获得数据后更新实例。

于 2013-12-07T18:37:26.037 回答
0

从网络加载图像时检查背景。

您从相机获取图像,但请注意,当您执行 mimetype = img/* 的资源选择器时,选择器只会将本地相机(图库)存储与其他照片、内容提供者合并。照片的常用选择器的一个示例是在“Evernote”中,您可以在其中使用 2X2 网格进入作曲家视图并触摸“附件”图标...这是一个照片选择器...

换句话说,它有助于理解管理照片和在 imageViews 中呈现照片的一般做法。

通常,有一个lazyLoader,它有一个接口,带有用于imgView 的args 和图像源的URI。在调用 'loadImage(view, uri) 的幕后,实现检查以下内容:

位图是否已经在 memCache 中?

支持位图的本地文件是否存在于为此目的保留的文件夹中?

如果以上都不是,请从网络中获取 img 的字节数组(或者在您的情况下,从相机获取字节)。

即使您的问题有点不同,IMO,图像的标准做法也可能适用,您可能希望根据您的特定要求调整用于图像呈现的众多库之一。

于 2013-12-07T21:38:26.280 回答