sabri allani
sabri allani

Reputation: 27

How to get Image from HashMap in android?

        map = new HashMap<String, String>();
        map.put("titre", "Orange TN");
        map.put("WebSite","http://www.orange.tn/");
        map.put("mail","[email protected]" );
        map.put("number","31 11 11 51");
        map.put("description", "Telecommunication - téléphonie fixe - téléphonie mobile - GSM - Internet - réseau - GPS - Andoid_iphone");
        map.put("lat","35.67233");
        map.put("longi","10.101422");
        map.put("img", String.valueOf(R.drawable.orange));
        listItem.add(map);

the problem is i want to do this when i do map.get("img") this return a String and i want a drawable type , then i can put it in an Imageview Type . and thxxx so much for help

Upvotes: 0

Views: 2777

Answers (1)

K_Anas
K_Anas

Reputation: 31466

    map = new HashMap<String, Object>();
    map.put("titre", "Orange TN");
    map.put("WebSite","http://www.orange.tn/");
    map.put("mail","[email protected]" );
    map.put("number","31 11 11 51");
    map.put("description", "Telecommunication - téléphonie fixe - téléphonie mobile - GSM - Internet - réseau - GPS - Andoid_iphone");
    map.put("lat","35.67233");
    map.put("longi","10.101422");
    map.put("img", R.drawable.orange);
    listItem.add(map);

After that you can use

image1.setImageDrawable( getResources().getDrawable( map.get("img") );

Upvotes: 3

Related Questions