开发者

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

开发者 https://www.devze.com 2023-04-11 03:47 出处:网络
I have an ArrayList object like this: ArrayList<HashMap<String, String>> data = new 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 HashMaps 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... }

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号