My application dynamically inserts OverlayItem objects throughout its
lifetime, without ever throwing a loading dialog to block user input.
If you're doing the same and you've been getting an
ArrayIndexOutOfBoundsException in getIndexToDraw of ItemizedOverlay,
here's what I did to fix the problem. Before my changes, my size()
looked something like this:

private ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();

public int size() {
    return items.size();
}


For the fix, I first created an instance field that is updated after
inserting a group of OverlayItem objects:

for (OverlayItem newItem : newItems) {
    items.add(newItem);
}
mSize = items.size();
populate();


Finally, override size() so that instead of automatically to returning
your collection's size, return the field that was written to manually:

public int size() {
    return mSize;
}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to