user1166635
user1166635

Reputation: 2801

How to add OnClickListener for items from ItemizedOverlay

I have following class extended ItemizedOverlay. This class draws many icons on Google Map (MapView). I need to make a listener for clicking by any item of ItemizedOverlay, but I don't know how I can do it. I hope you can help me. Thank you.

Upvotes: 0

Views: 140

Answers (1)

Michal K.
Michal K.

Reputation: 44

you should overide onTap() method of your ItemizedOverlay class.

 @Override
    protected boolean onTap(int index) {
        // TODO Auto-generated method stub
        final OverlayItem items = mapOverlay.get(index); //items is your ArrayList<OverlayItem> for populating of ItemizedOverlay

        //insert your code for action there
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();

        return true;
    }

I hope this helps.

Upvotes: 1

Related Questions