2

我遇到问题。我试图从在线来源检索图像,并将图像设置为ListViewImageView。但是,我不能这样做,因为我不能链接我的ImageViewListView内,因为它返回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类使用ViewBinderListView内插入下载的图像到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 ” 以及*

回答

0

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

相关问题