无法使用SimpleAdapter,ViewBinder和Asynctask从ListView将图像设置为ImageView

时间:2011-05-12 06:17:56

标签: android android-listview android-asynctask android-imageview android-viewbinder

我有问题。我正在尝试从在线来源检索图片,并将图片设置为ListView的{​​{1}}。但是,我无法这样做,因为我无法在ImageView内链接ImageView,因为它返回ListView。我意识到我必须使用NullPointerException将图片设置为VieWBinder内的ImageView
目前,我正在使用here中的ListView课程以及here中的ImageLoader课程。
这是我的ViewBinder类:

ViewBinder

SearchResults sr = new SearchResults(); ImageDownloader imageDownloader = new ImageDownloader(); @Override public boolean setViewValue(View view, Object data, String textRepresentation) { if (view instanceof ImageView && data instanceof Bitmap) { // TODO Auto-generated method stub for (int i = 0; i < sr.listData.size(); i++) { String imageISBN = sr.listData.get(i).get("coverImage"); ImageView iv = (ImageView) view; Bitmap bm = (Bitmap) data; imageDownloader.download(imageISBN,iv); //iv.setImageBitmap(bm); return true; } } return false; } 是一个我得到listData的类,其中包含像图像的url这样的数据。如何使用SearchResults类使用ImageLoader将下载的图像插入ImageView中的ListView

*旁注:它会给我一个错误“05-12 13:16:37.195:INFO / System.out(736):resolveUri在错误的位图uri上失败:http://lib.syndetics.com/index.aspx?isbn=9780137081851/SC.GIF&client=tpoly&type=xw12  “以及 *

1 个答案:

答案 0 :(得分:0)

为图像视图设置标记,例如说明图像的URL。并在您的onPostExecute中按列表view.findViewByTag获取图像视图。我不同意使用asynctask来获取图像,因为如果你的列表视图有很多列表项,会有很多asynctask。

相关问题