In my database I am storing data on various tourist attractions. I'm also storing the name of an image for each attraction, e.g. caste.jpg
. The following method adds all written data to the text fields but I don't know how to add the image to the ImageView. Any help?
public void updateDisplay()
{
// get the comments
attractions = db.getAttractions();
// create a List of Map<String, ?> objects
ArrayList<HashMap<String, String>> data =
new ArrayList<HashMap<String, String>>();
for (Attraction attraction : attractions) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", attraction.getName());
map.put("times", attraction.getOpeningTimes());
map.put("descr", attraction.getDesc());
map.put("price", attraction.getPrice());
data.add(map);
}
// create the resource, from, and to variables
int resource = R.layout.listview_attraction;
String[] from = {"name", "times", "descr", "price", "web"};
int[] to = {R.id.name, R.id.times, R.id.descr, R.id.price, R.id.web};
// create and set the adapter
SimpleAdapter adapter =
new SimpleAdapter(this, data, resource, from, to);
attractionListListView.setAdapter(adapter);
}