简体   繁体   中英

How to iterate Arraylist<HashMap<String,String>>?

I have an ArrayList object like this:

ArrayList<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();

How to iterate through the list? I want to display the value in a TextView which comes from the data of ArrayList object.

Simplest is to iterate over all the HashMap s in the ArrayList and then iterate over all the keys in the Map :

TextView view = (TextView) view.findViewById(R.id.view);

for (HashMap<String, String> map : data)
     for (Entry<String, String> entry : map.entrySet())
         view.append(entry.getKey() + " => " + entry.getValue());

for(HashMap<String, String> map : data){ ... deal with map... }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM