I am trying to add an image to this list.

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.offers);
    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
    String xml = XMLfunctions.getX## Heading ##ML();
    Document doc = XMLfunctions.XMLfromString(xml);
    int numResults = XMLfunctions.numResults(doc);
    if((numResults <= 0))
    {
        Toast.makeText(OffersActivity.this, "Geen resultaten gevonden", Toast.LENGTH_LONG).show();  
        finish();
    }
    ImageView newImg = (ImageView) findViewById(R.id.thumbimage);
    NodeList nodes = doc.getElementsByTagName("result");
    for (int i = 0; i < nodes.getLength(); i++)
    {
        HashMap<String, String> map = new HashMap<String, String>();
        Element e = (Element)nodes.item(i);
        map.put("id", XMLfunctions.getValue(e, "id"));
        map.put("name", "" + XMLfunctions.getValue(e, "name"));
        map.put("Score", "" + XMLfunctions.getValue(e, "score"));
        map.put("thumbnail", "" + XMLfunctions.getValue(e, "thumbimg"));
        mylist.add(map);
    }
    ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.listitems, 
            new String[] { "name", "Score",  "thumbnail"}, 
            new int[] { R.id.item_title, R.id.item_subtitle, R.id.thumbimage });
    setListAdapter(adapter);
}

I have the addresses of the images that I want to display in

map.put("thumbnail", "" + XMLfunctions.getValue(e, "thumbimg"));

And I get them too. In fact, they come from live xml. And I want to put them in the image. Please, help!

thank

+3
source share
2 answers

You need to download images in the background and then install them in the correct ImageViews.

Adapters do not provide you with all of these features by default, so you will need to do some extra coding yourself.

Take a look at this StackOverflow answer: lazy loading images in a ListView and you will see what I mean!

+2
source

LazyListview. , . . , , , .

, ....: -)

+1

All Articles