我有一个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);
我该如何解决这个问题?