tania
tania

Reputation: 1086

How do I add custom buttons into the balloon android-mapviewbaloons?

I use this nice library for showing balloons: MapViewBalloons

How do I add any buttons into the balloon? I would like to add a button with functionality of adding the current place into favorites! is it possible? thank you very much.

Code:

        mapOverlays = mapView.getOverlays();
        drawable = getResources().getDrawable(android.R.drawable.star_big_on);
        itemizedOverlay = new ItemsOverlay(drawable, mapView);          
        GeoPoint point = new GeoPoint((int)(51.5174723*1E6),(int)(-0.0899537*1E6));
        OverlayItem overlayItem = new OverlayItem(point, "Title", 
                "text");

Upvotes: 1

Views: 878

Answers (1)

Hesham Saeed
Hesham Saeed

Reputation: 5378

You should add a button inside your balloon_overlay.xml, then in your BalloonOverlayView.java class you should have setupView() function, inside that function you should add something like this:

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.balloon_overlay, parent);

Button favorite = (Button) v.findViewById(R.id.favorite);

favorite.setOnClickListener(new OnClickListener() {
//your code here
});

Upvotes: 2

Related Questions