从android google maps v2上的custominfowindow获取价值?

从android google maps v2上的custominfowindow获取价值?,android,google-maps,google-maps-android-api-2,infowindow,Android,Google Maps,Google Maps Android Api 2,Infowindow,我实现了在android设备上显示custominfowindow google maps v2的教程 这里是mainActivity.java中的代码 final Marker hamburg = googleMap.addMarker(new MarkerOptions().position(HAMBURG) .title("Hamburg")); markers.put(hamburg.getId(), "http:/

我实现了在android设备上显示custominfowindow google maps v2的教程 这里是mainActivity.java中的代码

final Marker hamburg = googleMap.addMarker(new MarkerOptions().position(HAMBURG)
                        .title("Hamburg"));
            markers.put(hamburg.getId(), "http://img.india-forums.com/images/100x100/37525-a-still-image-of-akshay-kumar.jpg");
下面的代码是同一文件中自定义infowindow的类

private class CustomInfoWindowAdapter implements InfoWindowAdapter{

        private View view;

        public CustomInfoWindowAdapter() {
            view = getLayoutInflater().inflate(R.layout.custom_info_window,
                    null);
        }

        @Override
        public View getInfoContents(Marker marker) {
            if (MapV2InfoWindow.this.marker != null
                    && MapV2InfoWindow.this.marker.isInfoWindowShown()) {
                MapV2InfoWindow.this.marker.hideInfoWindow();
                MapV2InfoWindow.this.marker.showInfoWindow();
            }
            return null;
        }

        @Override
        public View getInfoWindow(final Marker marker) { 
            MapV2InfoWindow.this.marker = marker;

            String url = null;

            if (marker.getId() != null && markers != null && markers.size() > 0) {
                if ( markers.get(marker.getId()) != null &&
                        markers.get(marker.getId()) != null) {
                    url = markers.get(marker.getId());
                }
            }
            final ImageView image = ((ImageView) view.findViewById(R.id.badge));

            if (url != null && !url.equalsIgnoreCase("null")
                    && !url.equalsIgnoreCase("")) {
                imageLoader.displayImage(url, image, options,
                        new SimpleImageLoadingListener() {
                            @Override
                            public void onLoadingComplete(String imageUri,
                                    View view, Bitmap loadedImage) {
                                super.onLoadingComplete(imageUri, view,
                                        loadedImage);
                                getInfoContents(marker);
                            }
                        });

            } else {
                image.setImageResource(R.drawable.ic_launcher);
            }

            final String title = marker.getTitle();
            final TextView titleUi = ((TextView) view.findViewById(R.id.title));
            if (title != null) {
                titleUi.setText(title);
            } else {
                titleUi.setText("");
            }

            final String snippet = marker.getSnippet();
            final TextView snippetUi = ((TextView) view
                    .findViewById(R.id.snippet));
            if (snippet != null) {
                snippetUi.setText(snippet);
            } else {
                snippetUi.setText("");
            }

            //final String txtGambarPp=url;
            final TextView txtGambarPpUi = ((TextView) view
                    .findViewById(R.id.txtImagePpSource));
            if (snippet != null) {
                txtGambarPpUi.setText(url);
            } else {
                txtGambarPpUi.setText("kosong");
            }
            return view;
        }
    }
customInfowindow.xml(LinearLayout)


我成功运行此应用程序并在infowindow中显示信息,如果我想从标题中获取值,我只需调用
marker.getTitle
并成功返回标题,但我想在infowindow中添加除标题和代码片段以外的信息,因此我使用textview添加xml(在这种情况下,我将id textview设置为
@+id/TXTMagePPSource
)当我运行应用程序仍然成功,但我的问题是,我想从信息窗口事件单击的文本视图中获取价值?我如何实现这一点,如果我想从标题中获取价值,只需调用marker.getTitle,那么如何使用txtmageppsource


谢谢

您只需将信息作为
/
单独添加到
标记标题中
,然后在自定义窗口中获取标题并使用
标题提取该字符串。拆分(“/”
)。一个接一个地用你的
文本视图绑定
不,我不能用它,因为标题必须是原创的,否则就没有办法了。所以infowindow只需在标题和代码片段中给出字符串结果?如果你知道关于custominfowindow的链接讨论,你可以告诉我,我非常需要它。。
<ImageView
    android:id="@+id/badge"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_marginRight="5dp"
    android:adjustViewBounds="true" >
</ImageView>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:singleLine="true"
        android:textColor="#ff000000"
        android:textSize="14dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/snippet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#ff7f7f7f"
        android:textSize="14dp" />
    <!-- I add this textview to show information about image -->
    <TextView
        android:id="@+id/txtImagePpSource"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="source image"/>
</LinearLayout>