![](/img/trans.png)
[英]Custom InfoWindowAdapter is not calling from onMarkerClick()
[英]Custom InfoWindowAdapter has no background
我在设计应用程序时遇到了一个奇怪的问题,用户可以在Google map ver 2上看到什么?
而且我已经像这样使用InfoWindowAdapter:
public class PopupAdapter implements InfoWindowAdapter {
LayoutInflater inflater=null;
View view;
public PopupAdapter(LayoutInflater inflater) {
this.inflater=inflater;
view = this.inflater.inflate(R.layout.custom_info_window,null);
}
@Override
public View getInfoContents(Marker marker) {
// TODO Auto-generated method stub
return null;
}
@Override
public View getInfoWindow(Marker marker) {
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("");
}
return view;
}
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher"/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"/>
</LinearLayout>
</LinearLayout>
但是当我在标记上弹出窗口时,它没有任何背景,并且在地图上仅显示了一个没有弹出框的简单文本
我试图解决此问题,但似乎有些不正常的人可以帮助我吗? 非常感谢
但是当我在标记上弹出窗口时,它没有任何背景,并且在地图上仅显示了一个没有弹出框的简单文本
这就是您要求它通过重写getInfoWindow()
来执行的操作。 如果要使用标准信息窗口框架,请改写getInfoContents()
。 或者,将您自己的框架作为从getInfoWindow()
返回的View
一部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.