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。

相關問題