【发布时间】:2013-05-11 01:02:13
【问题描述】:
我有一个ArrayList<HashMap<String, String>> placesListItems。
当我从placesListItems 中删除地图时,空地图仍然存在。这样我的ListAdapter 包含空列表项。
for (HashMap<String, String> map : placesListItems) {
for (Entry<String, String> entry : map.entrySet()) {
for (int j = 0; j < duplicateList.size(); j++) {
if (entry.getValue().equals(duplicateList.get(j))) {
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, String> pairs = (Entry)iterator.next();
System.out.println(pairs.getKey() + " = " + pairs.getValue());
iterator.remove(); // avoids a ConcurrentModificationException
}
}
}
}
}
ListAdapter adapter = new ItemAdapterHome(getApplicationContext, placesListItems);
lv.setAdapter(adapter);
我该如何解决这个问题?
【问题讨论】:
-
你能对你的缩进做点什么吗?
-
您永远不会从 placesListItems 列表中删除任何内容。
-
从地图中删除键值,而不是值。