listview about adapter, for create a hashmap, why bitmap type imported cannot show image in listview?

戏子无情 提交于 2019-12-11 23:15:09

问题


   list_data = list_data_add("111","222",icon);

    adapter = new SimpleAdapter(
            this, list_data, R.layout.list_item_detail,
            new String[]{"title","desc","icon"},
            new int[]{R.id.title, R.id.desc, R.id.icon}
    );
    listview.setAdapter(adapter);

private List<Map<String, Object>> list_data_add(String title, String desc, Bitmap icon) {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        Map<String, Object> map;
        map = new HashMap<String, Object>();

        map.put("title", title);
        map.put("desc", desc);
        map.put("icon", icon);
        list.add(map);

    return list;
} 

hi, the icon is Bitmap type, but this way it doesn't show any image in listview, but if change icon to int type, and set icon = R.drawable.icon_folder , and import to list_data_add to create a hashmap, it could show a android drawable resource image in listview.

so, could anyone can help me to solve this? tks!


回答1:


ok i got it, SimpleAdapter does not accpect Bitmap, create a baseadapter then it's fine.



来源:https://stackoverflow.com/questions/6708759/listview-about-adapter-for-create-a-hashmap-why-bitmap-type-imported-cannot-sh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!