在使用ListView的时候,List中有一个ImageView,用SimpleAdapter只能加载R.drawable.xxx这种写法的图片显示在ListView上,我现在从网络动态加载的图片转换成Bitmap或者Drawable后不知道怎么显示了...public class DirectList extends ListActivity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this, getData(), R.layout.tab_direct, new String[] { "title", "info", "img" }, new int[] { R.id.tab_driect_title, R.id.tab_driect_info, R.id.tab_driect_img });setListAdapter(adapter);}
private List<Map<String, Object>> getData() {List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();map.put("text", "测试文字");map.put("img", R.drawable.icon);//这里的R.drawable.icon怎么才能换成Drawable对象
return list;}
}

解决方案 »

  1.   

    转换Bitmap to Drawable
    itmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;     
    Drawable drawable = (Drawable)bitmapDrawable;     or    
        
    Bitmap bitmap = new Bitmap (...);     
    Drawable drawable = new BitmapDrawable(bitmap);  转换Drawable to Bitmap
    Drawable d = ImagesList.get(0);  
    Bitmap bitmap = ((BitmapDrawable)d).getBitmap();  
      

  2.   

    写自己的Adapter实现了,还是谢谢楼上的。
      

  3.   

    我也是自己写了Adapter 实现,但是listview的点击事件监听不到,不知道楼主有没有遇见这种情况???