如何在谷歌地图上的InfoWindow上实现onclicklistener

时间:2015-08-04 09:51:14

标签: java android google-maps

我正在使用此WITH temp_res AS (SELECT amount FROM table_temp WHERE DC IN ('C','D')) SELECT amount amt FROM temp_res WHERE TO_NUMBER(amount) > 0; GoogleMap.InfoWindowAdapter的{​​{1}}上显示image,但我想在其上处理ImageView以显示其他InfoWindow }}

这是我的代码:

sliding events

1 个答案:

答案 0 :(得分:1)

根据here,您应该setImageBitmap而不是getInfoContents {/ 1}}。

示例代码:

getInfoWindow

custom_info_contents.xml:

class MyInfoWindowAdapter implements InfoWindowAdapter{

        private final View myContentsView;
        boolean not_first_time_showing_info_window;

        MyInfoWindowAdapter(){
            myContentsView = getLayoutInflater().inflate(R.layout.custom_info_contents, null);
        }

        @Override
        public View getInfoContents(Marker marker) {

            ImageView imageView = (ImageView)myContentsView.findViewById(R.id.imgView);

            TextView tvTitle = ((TextView)myContentsView.findViewById(R.id.title));
            tvTitle.setText(marker.getTitle());
            TextView tvSnippet = ((TextView)myContentsView.findViewById(R.id.snippet));
            tvSnippet.setText(marker.getSnippet());

            return myContentsView;
        }

有关详细信息,请参阅here和我在github here上的项目。

修改

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:orientation="horizontal">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:adjustViewBounds="true"
            android:src="@drawable/ic_launcher"
            android:id="@+id/imgView"/>
        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="12dp"
            android:textStyle="bold"/>
        <TextView
            android:id="@+id/snippet"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="10dp"/>
    </LinearLayout>

</LinearLayout>