Pedro,
I believe list.remove(object item) removes the first element has is
equal() to the one passed in.
To remove items by some other criteria (such as actual class), you've
got to iterate the list.
Note that removing elements while iterating has to be done by calling
remove() on the iterator. Calling remove() on the collection itself
while iterating is not supported, and throws an exception that says as much.
List<Overlay> list = mapView.getOverlays();
for (Iterator<Overlay> ite = list.iterator(); ite.hasNext(); )
{
Overlay ov = ite.next();
if (ov instanceof UserOverlay) {
ite.remove();
}
}
Hope this helps.
-- Kostya
15.09.2010 20:06, Pedro Teixeira пишет:
Hi,
I have an overlay list which I retrieve it like this:
List<Overlay> overlays = mapView.getOverlays();
So in this list I have elements of the type userOverlay and
picOverlay..
How can I do to erase ALL occurences of userOverlay but leave all the
others?
I've been playing around with the List methods but I can't make it
work, I've tried:
while(overlays.contains(userOverlay)==true){
overlays.remove(userOverlay);
}
Which made sense to me.. but it doesn't work..
any suggestions?
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en