i passing list of tags in forloop for iterate but its raised ConcurrentModificationException
public void clearTag() {
List<Tag> tags = binding.search.tagView.getTags();
Log.d(TAG, "clearTags: " + tags);
for (Tag tag : tags) {
Log.d(TAG, "clearTag: " + tag + " " + tag.getLayoutColor());
if (tag.getLayoutColor() == R.color.red) {
tags.remove(tag);
} else if (tag.getLayoutColor() == R.color.blue) {
tags.remove(tag);
} else if (tag.getLayoutColor() == R.color.green) {
tags.remove(tag);
}
}
updateTagVisibility();
//resetFilter();
}