【发布时间】: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