Android Here-API :如何将按钮添加到 Here 地图信息气泡

Android Here-API :How to add buttons to a Here maps infobubble

是否可以向 Here 地图信息气泡添加按钮。我检查了 Android here maps api 但没有发现任何有用的东西。只是想知道以前是否有人尝试过这个?

谢谢

您应该使用 InfoBubbleAdapter 来设置气泡布局:

Map hMap.setInfoBubbleAdapter(new Map.InfoBubbleAdapter() {
            @Override
            public View getInfoBubbleContents(MapMarker mapMarker) {
                return null;
            }

            @Override
            public View getInfoBubble(final MapMarker mapMarker) {
                View bubble;
                bubble = LayoutInflater.from(getActivity()).inflate(R.layout.tooltip_cluster, container, false);
                Button btn = (Button) bubble.findViewById(R.id.btnBubble);
                return bubble;
            }
        });

并在布局中定义按钮

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:background="#00f">

    <EditText
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center"
        android:hint="Hello World !"
        android:textColor="@android:color/white"
        android:background="#c0392b"/>

    <Button
        android:layout_below="@+id/btnBubble"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="click ME !"/>

</RelativeLayout>