Android google 地图问题的自定义信息窗口

Custom InfoWindow for Android google maps issue

我在我的 Android 应用程序中创建了自定义 infoWindowAdapter class,它使用 google 地图。
class 使用 GetInfoContents 和 xml 文件来创建 infoWindow
的内容 xml 包含一个 ImageView 和三个 TextView,我可以设法用自定义 infoWindow 添加一个标记,但它只会显示三个中的两个TextViews 而不是 ImageView,我不明白为什么。前两个 TextView 的字符串来自 .setText(marker.getTitle()); .setText(marker.getSnippet());第三个字符串是在 getInfoContents 中创建的。

代码:

@Override
public View getInfoContents(Marker marker) {

    if (popup == null) {

        popup = inflater.inflate(R.layout.infowindow_popup, null);
    }

    TextView tvTitle = (TextView) popup.findViewById(R.id.title);
    tvTitle.setText(marker.getTitle());

    TextView tvSnippet = (TextView) popup.findViewById(R.id.snippet) ;
    tvSnippet.setText(marker.getSnippet());

    String test2 = "test 2";

    TextView tvSnippet2 = (TextView) popup.findViewById(R.id.snippet_2) ;
    tvSnippet2.setText(test2);

    return null;
}

你应该

return popup;

而不是

return null;

在你的getInfoContents(...)