Populate a ListView from an ArrayList<HashMap<String, String>>
<p>I have an <code>ArrayList&lt;HashMap&lt;Contact, Name&gt;&gt;</code> and I want to populate a <code>ListView</code> with it. Here's my attempt (which is not working)</p>

<pre><code>    ArrayList&lt;HashMap&lt;String, String&gt;&gt; lista = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

    // Array of strings "titulos"
    String titulos[] = { "Dolar (Transferencia)", "Euro (Transferencia)",
        "Dolar (Efectivo)", "Euro (Efectivo)", "Dolar (cúcuta)",
        "Euro (cucuta)" };

    try {
        JSONObject json = result; // result is a JSONObject and the source is located here: https://dl.dropbox.com/u/8102604/dolar.json
        JSONObject root = json.getJSONObject("root"); 
        JSONArray items = root.getJSONArray("item");
        int j = 0; 

        for (int i = 0; i &lt; items.length(); i++) {
            JSONObject item = items.getJSONObject(i);
            String key = item.getString("key");
            String mount = item.getString("mount");
            if (key.equals("TS") || key.equals("TE") || key.equals("EE")
                    || key.equals("CE") || key.equals("ES")
                    || key.equals("CS")) { // i did this since i only need the items where the key is equal to TS, TE, EE, CE, ES or CS.
                HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                map.put("id", String.valueOf(i));
                map.put(key, mount);
                lista.add(map);
                System.out.println(titulos[j] + "(" + key + "). BsF = " + mount); // just for debugging purposes
                j++; // add 1 to j if key is equal to TS, TE, EE, CE, ES or CS. In this way i can associate the two arrays (item and titulos)
            }
        }

        ListView lv = (ListView) myMainActivity.findViewById(R.id.listView1); // create a list view 
        lv.setAdapter(new ArrayAdapter&lt;String&gt;(contexto, android.R.layout.simple_list_item_1, lista)); // set adapter to the listview (not working)

    } catch (JSONException e) {
        Log.e("log_tag", "Error parsing data " + e.toString());
    }
}
</code></pre>

<p>That last line is throwing an error in eclipse:</p>

<pre><code>The constructor ArrayAdapter&lt;String&gt;(Context, int, ArrayList&lt;HashMap&lt;String,String&gt;&gt;) is undefined
</code></pre>

<p>I've tried everything but I still couldn't make it work, could you help me please?</p>

<p>Thanks in advance.</p>

<p>PS: Full source: <a href="https://gist.github.com/4451519" rel="nofollow">https://gist.github.com/4451519</a></p>
