Is it possible to pass both strings and drawables as objects in the same HashMap, and then use this hashmap to populate a ListView via SimpleAdapter ?
I want this because I first get JSON data which also contains the URL to a thumbnail. Then I download this thumbnail. Relevant code (I think):
for (...) {
...
InputStream is = (InputStream)content;
Drawable image = Drawable.createFromStream(is, "src");
// Hashmap
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("title", new String(jsonObject.getString("Title")));
map.put("thumb", image);
mylist.add(map);
}
ListAdapter adapter = new SimpleAdapter(getActivity(), mylist, R.layout.listitem,
new String[] { "title", "thumb"},
new int[] { R.id.title, R.id.thumb });
setListAdapter(adapter);
R.id.title = TextView, and R.id.thumb = ImageView
This works for the title string, but not for the drawable. Is this approach just stupid?
Thanks in advance.