Java 如何将线条和按钮添加到标记?
当用户使用Java 如何将线条和按钮添加到标记?,java,android,marker,mapactivity,Java,Android,Marker,Mapactivity,当用户使用marker类的片段单击标记时,我试图显示一些信息。据我所知,问题是它只能有一行长,所以我无法添加一行新行以使信息更清晰。有没有办法显示多行 我正在使用默认的MapActivity和谷歌地图API V2 提前感谢您的耐心和考虑。您可以创建自定义信息窗口。看看这个码头 适配器示例: public class CustomInfoWindow implements GoogleMap.InfoWindowAdapter { Context context; LayoutI
marker
类的片段单击标记时,我试图显示一些信息。据我所知,问题是它只能有一行长,所以我无法添加一行新行以使信息更清晰。有没有办法显示多行我正在使用默认的
MapActivity
和谷歌地图API V2提前感谢您的耐心和考虑。您可以创建自定义信息窗口。看看这个码头 适配器示例:
public class CustomInfoWindow implements GoogleMap.InfoWindowAdapter {
Context context;
LayoutInflater inflater;
public CustomInfoWindow(Context context) {
this.context = context;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
@Override
public View getInfoWindow(Marker marker) {
inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// R.layout.custom_info_window is a layout
// res/layout folder. You can provide your own
View v = inflater.inflate(R.layout.custom_info_window, null);
TextView title = (TextView) v.findViewById(R.id.info_window_title);
TextView subtitle = (TextView) v.findViewById(R.id.info_window_subtitle);
title.setText(marker.getTitle());
subtitle.setText(marker.getSnippet());
return v;
}
}
要使用它,您需要:
map.setInfoWindowAdapter(新的CustomInfoWindow(上下文))代码>您可以创建自定义信息窗口,并制作如下mMap.setInfoWindowAdapter(customInfoWindow)@瓦迪梅克斯勒,你能说得更准确些吗?“自定义信息窗口”是什么意思?你可以添加一些代码吗?看看我的回答我可以在自定义信息窗口中添加按钮吗?对于两个按钮,你可以使用这个按钮好的,非常感谢!