如何让在谷歌地图标记InfoWindowAdapter链接点击 [英] How to make a link clickable in a Google Map Marker InfoWindowAdapter
问题描述
我显示夫妇在谷歌地图标记。
当我点击一个标记,它会打开一个自定义InfoWindowAdapter
I'm displaying a couple of markers on a Google Map. When I click on a marker it opens a custom InfoWindowAdapter
this.map.setInfoWindowAdapter(new CustomInfoWindowAdapter(getLayoutInflater()));
在此CustomInfoWindowAdapter我显示一些文本,并创建时的电话号码找到了一个链接:
In this CustomInfoWindowAdapter I display some text and create a link when a phone number is found:
@Override
public View getInfoContents(Marker marker) {
if (this.popup == null) {
this.popup = inflater.inflate(R.layout.poi_marker, null);
}
TextView tv = (TextView) popup.findViewById(R.id.title);
tv.setText(marker.getTitle());
tv = (TextView) popup.findViewById(R.id.snippet);
tv.setText(marker.getSnippet());
Linkify.addLinks(tv, Linkify.PHONE_NUMBERS);
return(popup);
}
接着显示器正确。我可以看到电话号码显示为一个链接,但我不能美元,它p $ PSS ...
我如何我可以把它打开拨号程序?
The display is then correct. I can see that the phone number is displayed as a link, but I cannot press on it... How I can I make it open the dialer ?
推荐答案
我终于成功地做这样的:
I finally managed to do it like that:
是的,但问题是手机解析;)
Yes but the problem IS the phone parsing ;)
我设法那样做
this.map.setOnInfoWindowClickListener(新OnInfoWindowClickListener(){
this.map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
final String description = marker.getSnippet();
if (!TextUtils.isEmpty(description)) {
final Spannable span = Spannable.Factory.getInstance().newSpannable(description);
if (Linkify.addLinks(span, Linkify.PHONE_NUMBERS)) {
final URLSpan[] old = span.getSpans(0, span.length(), URLSpan.class);
if (old != null && old.length > 0) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(old[0].getURL()));
startActivity(intent);
}
}
}
}
});
这篇关于如何让在谷歌地图标记InfoWindowAdapter链接点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!