【问题标题】:Custom InfoWindow for Android google maps issueAndroid 谷歌地图问题的自定义信息窗口
【发布时间】:2015-03-29 19:03:08
【问题描述】:

我在使用谷歌地图的 Android 应用程序中创建了一个自定义 infoWindowAdapter 类。
该类使用 GetInfoContents 和一个 xml 文件来创建 infoWindow 的内容
该 xml 包含一个 ImageView 和三个 TextView,我可以设法使用自定义 infoWindow 添加一个标记,但它只会显示三个 TextView 中的两个,并且没有 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;
  • :|我不敢相信我已经做到了
  • 是的,有效...谢谢!

标签: android google-maps google-maps-android-api-2 infowindow


【解决方案1】:

你应该

return popup;

而不是

return null;

在你的getInfoContents(...)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-20
    • 2013-01-06
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多