codereviewanskquestions
codereviewanskquestions

Reputation: 14008

Android overlay item

I want to create an overlay item so if a user taps on the overlay item then a dialog with list view pops up. How do I do this?

Thanks in advance..

Upvotes: 1

Views: 1073

Answers (1)

Goldsmith
Goldsmith

Reputation: 508

You need to create your own overlay by extending ItemizedOverlay. You can override the onTap() method to do whatever you want when an item is tapped.

Basic silly example:

public class CustomOverlay extends ItemizedOverlay<OverlayItem> {
    private Activity mContext;


    public CustomOverlay(Activity activity, Drawable defaultIcon) {
        super(defaultIcon);
        mContext = activity;
    }

    @Override
    protected boolean onTap(int index) {
        new AlertDialog.Builder(mContext).setItems(...
        /* Etc. - You can show the dialog here. */
    }
}

Upvotes: 1

Related Questions