I have a hashmap array I am putting info into from an XML file. How should I download the image to make it available in my listview?
Here is my code:
public void dealsCb(String url, XmlDom xml, AjaxStatus status) {
List<XmlDom> products = xml.tags("Product");
List<HashMap<String, String>> titles = new ArrayList<HashMap<String, String>>();
for (XmlDom product : products) {
HashMap<String, String> hmdata = new HashMap<String, String>();
hmdata.put("title", product.text("Product_Name"));
hmdata.put("desc", product.text("Sale_Price"));
//NEED TO DOWNLOAD IMAGE FROM THIS URL AND THEN ADD TO ARRAY....
hmdata.put("thumb", product.text("Image_URL"));
titles.add(hmdata);
}
String[] from = { "thumb", "title", "desc" };
int[] to = { R.id.icon, R.id.title, R.id.desc };
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), titles,
R.layout.activity_deals_item, from, to);
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
}
I have tried a method that gets the image, makes it a bitmap, then converts it to a drawable, but am no able to add it to the array since hmdata.put takes a string... What am I missing with the image loading?