在下面的循环marker
中是一个列表,它被迭代并且每个项目都被绘制在画布上。但是,随着循环的进行,我相信以前的引用已被破坏。如何为循环的每次运行创建一个唯一的实例?
//Draw AR markers in reverse order since the last drawn should be the closest
ListIterator<Marker> iter = collection.listIterator(collection.size());
while (iter.hasPrevious()) {
Marker marker = iter.previous();
marker.draw(canvas);
}
我尝试了以下但无济于事。循环到达第二个项目然后有一个 NoSuchElementException。
while (iter.hasPrevious()) {
int i = 0;
try {
Marker marker = iter.previous();
marker.draw(canvas);
++i;
System.out.println("Item number 1 " + i);
Marker marker1 = iter.next();
marker1.draw(canvas);
++i;
... repeated up to marker7 then catching the NoSuchElementException.