我遇到问题。我试图从在线来源检索图像,并将图像设置为ListView
的ImageView
。但是,我不能这样做,因为我不能链接我的ImageView
在ListView
内,因为它返回NullPointerException
。我意识到我必须使用VieWBinder
将图像设置为ListView
内的ImageView
。
目前,我正在使用here中的ImageLoader
类以及here中的ViewBinder
类。
这是我ViewBinder类:无法使用SimpleAdapter,ViewBinder和Asynctask从ListView将图像设置到ImageView中
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;
}
SearchResults
是一类在那里我得到了包含类似的URL图像数据的listData。我怎么能使用ImageLoader
类使用ViewBinder
在ListView
内插入下载的图像到ImageView
?
*附注:它将给我一个错误 “05-12 13:16:37.195:信息/的System.out(736):resolveUri失败的坏位URI:http://lib.syndetics.com/index.aspx?isbn=9780137081851/SC.GIF&client=tpoly&type=xw12 ” 以及*