I want to set an image to a list view using a hash map, currently all data except the image is being set. How do i set the image using the hash map? The images are stored in the drawable folder. Below is my code.
// create a List of Map<String, ?> objects
ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
for (Attraction attraction : attractions) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put(attraction_name, attraction.getName());
map.put("img", String.valueOf(R.drawable.king));
data.add(map);
}
// create the resource, from, and to variables
int resource = R.layout.layout_att;
String[] from = {attraction_name, "img"};
int[] to = {R.id.name, R.id.img};
// create and set the adapter
SimpleAdapter adapter =
new SimpleAdapter(this, data, resource, from, to);
attractionListListView.setAdapter(adapter);
attractionListListView.setOnItemClickListener(this);
}