我是Android的初学者。我已经实现了谷歌地图v2,但我想要一个带有三个按钮的自定义信息窗口,我经历了文档,但默认的infowindow是单点击,它不能有按钮,任何方式或想法,我可以做到这一点。请帮助我。Android Google Map V2 InfoWindow
0
A
回答
1
你是什么试图实现是可能的。
你可以看到在这个答案配方:Google Maps Android API v2 - Interactive InfoWindow (like in original android google maps)
而且在Google Play
而且也在这里工作实施小tutorial
0
ü需要创建这样
class BalloonAdapter implements InfoWindowAdapter {
LayoutInflater inflater = null;
private Button Button1, Button2, Button3;
public BalloonAdapter(LayoutInflater inflater) {
this.inflater = inflater;
}
@Override
public View getInfoWindow(Marker marker) {
User_ID = marker.getTitle();
View v = inflater.inflate(R.layout.map_ballon, null);
if(User_ID.equals("Your location")){
//Toast.makeText(getApplicationContext(), "your location", Toast.LENGTH_LONG).show();
textViewTitle = (TextView) v.findViewById(R.id.balloon_name);
textViewTitle.setText(marker.getTitle());
}else{
if (marker != null) {
image = (ImageView) v.findViewById(R.id.balloon_image);
Button1= (Button) v.findViewById(R.id.balloon_name);
Button2 = (Button) v.findViewById(R.id.balloon_age);
Button3 = (Button) v.findViewById(R.id.balloon_id);
Button1.setText(marker.getTitle());
Button2.setText(marker.getSnippet());
Button3.setVisibility(View.GONE);
imageLoader.DisplayImage(ImageLoad, image);
Button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//do wat do u want with this button
}
});
Button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//do wat do u want with this button
}
});
Button3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//do wat do u want with this button
}
});
}
}
return v;
}
@Override
public View getInfoContents(Marker marker) {
return (null);
}
}
自定义窗口,你可以调用函数这样
map.addMarker(new MarkerOptions()
.position(
new LatLng(
Double.parseDouble(Latitude),
Double.parseDouble(Longitude)))
.title(User_ID + "\n" + "Name: " + CustomerName
+ "\n"+"Gender: " + Gender)
.snippet(PhoneNum+"\n"+ImageStatus+"*"+ImageLoad)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.maponinemarker)));
map.setInfoWindowAdapter(new BalloonAdapter(getLayoutInflater()));
这为u如何调用infowindo map.setInfoWindowAdapter(new BalloonAdapter(getLayoutInflater()));
相关问题
- 1. Google map Android API v2 - InfoWindow on polyline?
- 2. 隐藏infowindow android map api v2
- 3. Google Map v2 android
- 4. Android - Google map api v2&android 2.3.7
- 5. Google map infowindow position
- 6. Android Google Map v2 - 点击标记infoWindow时开始活动
- 7. Google Map V2 Android,“error import com.google.android.gms.maps.model.LatLng”
- 8. Android Google MAP V2 map.setMyLocationEnabled(true)
- 9. Android Google Map Api V2 OnCameraChangeListener
- 10. Google Map Infowindow关闭?
- 11. Google Map infowindow问题
- 12. Android Google Maps v2永久标记InfoWindow
- 13. Google Map API v2 java.lang.ClassNotFoundException:com.google.android.gms.maps.MapFragment
- 14. 将android map v1转换为google android map map v2
- 15. Google Map v2 for min API 10
- 16. 如何在Android中显示Google Map v2
- 17. Android Google Map v2绘制静态网格
- 18. Android Google Map V2身份验证问题
- 19. Android Google Map api v2返回null?
- 20. Android地图v2设置位置infoWindow
- 21. Google Map Api v2错误
- 22. Android Map v2绘图椭圆
- 23. Infowindow for Google Map中的圆形标记
- 24. 按钮事件InfoWindow Google Map APi
- 25. 在Google Map InfoWindow中更改背景色
- 26. 单击Infowindow后重置Google Map位置
- 27. Map is not loading Map api v2
- 28. 在添加标记Google Maps v2时自动打开InfoWindow Android
- 29. 如何运行google map sample v2?
- 30. Google Map Api v2没有地图视图
非常感谢@M D.我会试试这个。 –
@VishnuPrabhu这是有史以来最好的成就becoz'自定义信息窗口只提供一次点击,但你可以通过使用上述后解决方案实现特定的按钮点击 –
@MD自定义窗口也允许实现特定的按钮点击查看我的回答 – Jagan