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

Reply via email to