Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine
LogCat and look at your stack trace.

Since ItemizedOverlay requires you to have a numerically-indexed
collection of points, your current approach will be unreliable,
particularly as your data set changes.

On Wed, Dec 7, 2011 at 7:32 AM, Rhubarb <[email protected]> wrote:
> Hi
> I am looking for a technique for storing my Overlays in a hashmap
> (instead of arraylist) so I can delete them easily
>
> I tried the code below but it crashes, at it.next() with FATAL
> EXCEPTION.
>
> I realise i am making an assumption that populate() will iterate
> nicely from 0. But I think it should be OK
>
> class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
>
>        private ArrayList<OverlayItem> mOverlays = new
> ArrayList<OverlayItem>(); //OLD
>        private HashMap<String, OverlayItem> mHMOverlays = new
> HashMap<String, OverlayItem>();
>
> // pretty standard stuff until ....
>
>        @Override
>        protected OverlayItem createItem(int i) {
>                if (i == 0) {
>                        it = mHMOverlays.entrySet().iterator();
>                }
>
>                if (it.hasNext()) {
>                        OverlayItem x = (OverlayItem) it.next();               
>         //
> crashes here
>                        return x;
>                }
>                return null;
>        }
>
> Can anyone see why it would crash. I am at a loss
>
> I have seen an example that converts the hashmap to an array (in each
> call to createItem) but I suspect it would be very inneficient.
> LinkedHashMap might be the way to go
>
> Peter
>
> --
> 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



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

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