ArrayList<HashMap<String, String>> android take variables

19,117

This is example for log all key and value in hashmap

ArrayList<HashMap<String, String>> arrayList = new ArrayList<HashMap<String,String>>();
HashMap<String, String> h1 = new HashMap<String, String>();
h1.put("h1_key_1", "h1_value_1");
h1.put("h1_key_2", "h1_value_2");
arrayList.add(h1);

HashMap<String, String> h2 = new HashMap<String, String>();
h2.put("h2_key_1", "h2_value_1");
h2.put("h2_key_2", "h2_value_2");
arrayList.add(h2);

for (HashMap<String, String> hashMap : arrayList) {
    System.out.println(hashMap.keySet());
    for (String key : hashMap.keySet()) {
    System.out.println(hashMap.get(key));
    }
}
Share:
19,117
Sk8eR
Author by

Sk8eR

Updated on June 28, 2022

Comments

  • Sk8eR
    Sk8eR about 2 years

    How can i take all variables with tag URL for example?

    Of this kind of variable: ArrayList<HashMap<String, String>>?