经常用到List<Map<String,Object>>这种集合 , 这次的需求是遍历出里面的某些内容。废话不多,直接贴代码
List<LinkedHashMap<String, String>> b_LinkedMapData ;
for(LinkedHashMap<String, String> bMap:b_LinkedMapData){
for(@SuppressWarnings("rawtypes")
Iterator iter = bMap.entrySet().iterator();iter.hasNext();){
@SuppressWarnings("rawtypes")
LinkedHashMap.Entry element = (LinkedHashMap.Entry)iter.next();
Object strKey = element.getKey();
Object strObj = element.getValue();
Log.i("这是遍历的信息======>" , "myMap.get(\""+strKey+"\")="+strObj);
} }
如果你要获取map中的某个key中value
在循环最里面加上一下代码就可以
if (strKey != null && strKey.equals("b_customer_name")) {
String specialValue = element.getValue().toString();
Log.i("specialValue", specialValue);
}
参考 :http://www.heycode.com/a8008.html
以及 http://blog.csdn.net/hotjavaweb/article/details/7086459
以及 http://blog.csdn.net/zhaokuo719/article/details/7445770