重写viewbinder

public class viewbinder_bookmark implements SimpleAdapter.ViewBinder{
@Override
public boolean setViewValue(View view, Object data, String textRepresentation){
if(view instanceof ImageView && data instanceof Bitmap){
ImageView imageview=(ImageView)view;
Bitmap bitmap=(Bitmap)data;
imageview.setImageBitmap(bitmap);
return true;
}
return false;
}
}

再给simpleadapter设置viewbinder

List<Map<String,Object>> arraylist_bookmark=new ArrayList<Map<String,Object>>();
Map<String,Object> item_bookmark=new HashMap<String,Object>();
item_bookmark.put("bookmark_title","百度一下");
item_bookmark.put("bookmark_favicon",bitmap);
arraylist_bookmark.add(item_bookmark);
SimpleAdapter simpleAdapter=new SimpleAdapter(MainActivity.this ,arraylist_bookmark,R.layout.layout_bookmark_item,new String[]{"bookmark_title","bookmark_favicon"},new int[]{R.id.bookmark_title,R.id.bookmark_favicon});
simpleAdapter.setViewBinder(new viewbinder_bookmark());
listview_bookmark=(ListView)findViewById(R.id.listview_bookmark);
listview_bookmark.setAdapter(simpleAdapter);
05-28 03:41