The problem occurs at
Element element = it.next();
And this code which contains that line, is inside of an OnTouchEvent
You're not allowed to add an entry to a collection while you're iterating over it.
One option is to create a new List
for new entries while you're iterating over mElements
, and then add all the new ones to mElement
afterwards (mElements.addAll(newElements)
). Of course, that means you won't have executed the loop body for those new elements - is that a problem?
At the same time, I'd recommend that you update your code to use the enhanced for loop:
for (Element element : mElements) {
...
}