使用适配器传递值以查看
我已经实现了(感谢教程)一种显示自定义列表视图的方法,其中包含图像、名称和描述。
我使用 simpleAdapter
将字符串 name
和 description
传递给 textViews,以及图像 Id 的 int(图像存储在 R 中) .drawable)到imageView。
问题是:现在我应该设置 ImageViews 以显示从网络下载的图像,所以我有可绘制对象,但我无法从中获取 ID。
如何自定义 simpleAdapter 以将 Drawable
传递给 imageView
,并使用 setImageDrawable
方法设置图像?
请说清楚!谢谢
I've implemented (thanks to a tutorial) a way to show a custom listView, with images, names and description.
I used the simpleAdapter
to pass the strings name
and description
to the textViews, and the int of an image's Id (the image is stored in R.drawable) to the imageView.
The problem is: now i should set the ImageViews to display images downloaded from the web, so I have drawables but i can't get IDs from them.
How can i customize the simpleAdapter to pass a Drawable
to the imageView
, and set the image with the setImageDrawable
method?
Please be clear! Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
http://www.androidpeople.com/android-load -image-from-url-example/
或者从已下载的外部媒体文件加载:
Bitmap myBitmap = BitmapFactory.decodeFile(“/sdcard/myImage.jpg”);
ImageView myImage = (ImageView) findViewById(R.id.imageToShow);
myImage.setImageBitmap(myBitmap);
Try This:
http://www.androidpeople.com/android-load-image-from-url-example/
Or to load from External media files you have already downloaded:
Bitmap myBitmap = BitmapFactory.decodeFile(“/sdcard/myImage.jpg”);
ImageView myImage = (ImageView) findViewById(R.id.imageToShow);
myImage.setImageBitmap(myBitmap);
这相当困难...所以我建议使用 CommonsWare 的 ThumbnailAdapter。
This is quite difficult... so I would advise to use CommonsWare's ThumbnailAdapter.
我们需要使用viewBinder,如下所示:
We need to use the viewBinder, as show here: