嗨,我想在Android应用程序中将标记信息窗口添加到我的Google地图中。到目前为止,我已经添加了自定义信息窗口,并且它具有图像和按钮。单击标记后,我的目标显示信息窗口,然后在用户单击窗口中的按钮关闭了信息窗口并在单击按钮后进行了一些活动。但是我无法确定用户何时单击标记信息窗口中的按钮。这是我的代码。请告诉我代码中哪里出了问题。
googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
final View infoview = getLayoutInflater().inflate(R.layout.info_window,
null);
LatLng latLng = arg0.getPosition();
//tvLat.setText("Latitude:" + latLng.latitude);
//tvLng.setText("Longitude:" + latLng.longitude);
Button pickMe = (Button)infoview.findViewById(R.id.pickme);
pickMe.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Requested Send", Toast.LENGTH_SHORT).show();
}});
//String reverceGeoCode=new GetLocationAddress().getAddress(String.valueOf(latLng.latitude), String.valueOf(latLng.longitude));
//Toast.makeText(getApplicationContext(), "Rev :"+reverceGeoCode, Toast.LENGTH_LONG).show();
return infoview;
}
});
这是我的customInfo-window xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Sajith Vijesekara"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:src="@drawable/driver" />
<Button
android:id="@+id/pickme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:text="Pick Me" />
</LinearLayout>
</LinearLayout>
谢谢萨吉斯
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句