Android 无法使用SimpleAdapter、ViewBinder和Asynctask从ListView将图像设置为ImageView
我有个问题。我正在尝试从联机源检索图像,并将图像设置到Android 无法使用SimpleAdapter、ViewBinder和Asynctask从ListView将图像设置为ImageView,android,android-listview,android-asynctask,android-imageview,android-viewbinder,Android,Android Listview,Android Asynctask,Android Imageview,Android Viewbinder,我有个问题。我正在尝试从联机源检索图像,并将图像设置到列表视图的图像视图。但是,我不能这样做,因为我不能在列表视图中链接我的ImageView,因为它返回NullPointerException。我意识到我必须使用VieWBinder将图像设置到列表视图中的ImageView 目前,我正在使用中的ImageLoader类以及中的ViewBinder类。 这是我的ViewBinder类: SearchResults sr = new SearchResults(); ImageDownloader
列表视图
的图像视图
。但是,我不能这样做,因为我不能在列表视图中链接我的ImageView
,因为它返回NullPointerException
。我意识到我必须使用VieWBinder
将图像设置到列表视图中的ImageView
目前,我正在使用中的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;
}
SearchResults sr=新的SearchResults();
ImageDownloader ImageDownloader=新的ImageDownloader();
@凌驾
公共布尔setViewValue(视图、对象数据、字符串文本表示){
if(查看图像的实例查看位图的数据实例(&D){
//TODO自动生成的方法存根
对于(int i=0;i
SearchResults
是一个类,我从中获取listData,其中包含图像的url等数据。如何使用ViewBinder
使用ImageLoader
类将下载的图像插入ListView
中的ImageView
*旁注:这会给我一个错误“05-12 13:16:37.195:INFO/System.out(736):resolveUri在错误的位图uri上失败:
“此外*为图像视图设置标记,例如图像的URL。在onPostExecute中,通过list view.findViewByTag获取图像视图。我不同意使用asynctask获取图像,因为如果列表视图中有很多列表项,那么会有很多asynctask 为图像视图设置标记,例如图像的URL。在onPostExecute中,通过list view.findViewByTag获取图像视图。我不同意使用asynctask获取图像,因为如果列表视图中有很多列表项,那么会有很多asynctask