java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:)
at com.lh.technologysupport.view.activity.ResponseActivity.lambda$initDynamicEvents$$ResponseActivity(ResponseActivity.java:)
addTraffic.setOnClickListener(v -> {
String newTag = trafficClassChart.getText().toString().trim();
if (!StringUtil.isEmptyStr(newTag)) {
List<String> tagsNew = new ArrayList<>();
List<String> tags = tagContainerTraffic.getTags();
if (tags == null || tags.isEmpty()) {
tagsNew.add(newTag);
} else {
for (String s : tags) { // 改成 fori 循环 !
if (!s.equals(newTag)) {
tags.add(newTag);
}
}
tagsNew.addAll(tags);
}
tagContainerTraffic.setTags(tagsNew);
}
});
解决方式:把增强 for 改成 for(i) 循环!
参考:https://blog.csdn.net/wchicho/article/details/51987992