gpt4 book ai didi

android - 如何将自定义按钮添加到气球 android-mapviewbaloons 中?

转载 作者:行者123 更新时间:2023-11-29 22:01:26 24 4
gpt4 key购买 nike

我使用这个不错的库来显示气球:MapViewBalloons

如何将任何按钮添加到气球中?我想添加一个具有功能的按钮将当前位置添加到收藏夹!是否可以?非常感谢。

代码:

        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");

最佳答案

您应该在 balloon_overlay.xml 中添加一个按钮,然后在您的 BalloonOverlayView.java 类中您应该具有 setupView() 函数,在该函数中,您应该添加如下内容:

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
});

关于android - 如何将自定义按钮添加到气球 android-mapviewbaloons 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11819350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com