当我点击自定义信息窗口中的数字时,启动手机拨号器时出现问题。每次我点击地图api v2上的标记时,都会出现此信息。我想在标记的infowindow中显示一个电话号码,然后单击它以拨打屏幕(插入我的数字的启动拨号器)。
这是我的活动:
relheight
这是我的XML:
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(R.layout.infowindow_layout, null);
//start phone call
final TextView tvDialer =(TextView) v.findViewById(R.id.dialer);
tvDialer.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String phoneNo= tvDialer.getText().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" +phoneNo));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);
}
});
//end phone call
// Returning the view containing InfoWindow contents
return v;
}
你能帮我吗?
答案 0 :(得分:0)
绘制的信息窗口不是实时视图。视图在返回时呈现为图像(使用View.draw(Canvas))。这意味着对视图的任何后续更改都不会被地图上的信息窗口反映出来。要稍后更新信息窗口(例如,在加载图像后),请调用showInfoWindow()。此外,信息窗口将不会考虑正常视图(例如触摸或手势事件)的任何典型交互。但是,您可以在整个信息窗口中收听通用点击事件,如以下部分所述。
来自Google Maps V2文档:https://developers.google.com/maps/documentation/android/infowindows
我建议在点击标记时启用拨号程序调用,或者如果您有多条信息,则在点击标记时显示一些浮动视图(小窗口),在此视图上显示相关信息,然后设置拨打电话。
但如果你仍然想要追求你的要求,那就有一个解决方法。 请查看以下链接:Google Maps Android API v2 - Interactive InfoWindow (like in original android google maps)
您可以使用OnInfoWindowClickListener来监听信息窗口上的点击事件。要在地图上设置此侦听器,请调用GoogleMap.setOnInfoWindowClickListener(OnInfoWindowClickListener)。