elephantbug wrote:
> I extend the MapActivity and have an ItemizedOverlay which will
> display array of items(For example, people) on top of MapView.  These
> items' location are moving and some new items might be added in or
> some might be removed. There is another thread managing these items.
> 
> MapActivity is the observer of these items and update the UI whenever
> items changes. It works fine most of time. However, periodically, it
> will cause trouble and makes ItemizedOverlay throw ArrayOutofIndex
> exceptionrom  getIndexToDraw() method.
> 
> Anyone can help me why it might happen and what is the best practice
> to support dynamic data bind for ItemizedOverlay?

Without seeing your implementation of your ItemizedOverlay subclass, it 
is difficult to make many suggestions.

Bear in mind that if you change the data in a background thread, the 
foreground (UI) thread might still be working off of old information. 
For example, suppose you have six items, and the foreground thread is 
busy drawing those six items on the map. While that is happening, your 
background thread removes one item. The foreground thread has no way to 
know that occurred, so it will try requesting the sixth item...and will 
fail.

Since I don't know how you are telling the MapView that there is changed 
data in the ItemizedOverlay, I cannot make any particular suggestions of 
how to get around this problem. What *may* work is to change the 
contents of your ItemizedOverlay only on the foreground (UI) thread -- 
just have the background thread use a Handler or use runOnUiThread() or 
something to arrange for the work to get done on the foreground thread.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!

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