2013-12-21 36 views
1

我有一个奇怪的问题 我设计了一个应用程序有什么可以让用户看到谷歌地图某一点版本2定制InfoWindowAdapter没有背景

和我用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> 

,但是当我在我的标记得到弹出它不具有任何背景,它显示在地图上只是没有弹出FRAM一个简单的文本e

我试图解决这个问题,但它似乎有点不寻常 可以任何一个请帮帮我吗? 太感谢你了

回答

2

,但是当我在我的标记得到弹出它不具有任何背景,它显示在地图上只是没有弹出画面

一个简单的文本这就是你问它通过重写getInfoWindow()。如果您需要标准信息窗口框架,请改为getInfoContents()。或者,请将您自己的框架作为从getInfoWindow()返回的View的一部分。

+0

看看这些链接: http://android-er.blogspot.com/2013/01/custom-infowindowadapter-with-dynamic.html http://androidfreakers.blogspot.com/2013/08/display -custom-info-window-with.html 他们使用简单的布局.... –

+0

@PouyaSamie:第一个覆盖'getInfoContents()',而不是'getInfoWindow()'。第二个提供框架背景('@ drawable/custom_info_bubble')作为从'getInfoWindow()'返回的'View'的一部分。这些是我在答案中列出的两个解决方案。 – CommonsWare

+0

oppssss ....谢谢你这么muchhhhhhh –