How to open new activity (or dialog or link) from a Infowindow - Google Maps v2 Android

一笑奈何 提交于 2019-12-10 19:28:10

问题


I want to open a new activity (or a custom dialog or a link) from a infowindow. I want my UI works in this way:
1) I see the map
2) I click on a marker to show an Infowindow
3) I click a button (or something else) into the Infowindow to open a new activity (or a dialog) to show more information. Alternatively, I click a link into the Infowindow to open a webpage to show more information.

I would prefer to open a new activity or dialog. By the way, can you show me the easier way to do this? Any help will be greatly appreciated. Thanks in advance.
This is my code.

Marker INFO=mMap.addMarker(new MarkerOptions()
    .position(info)
    .title("TITLE")
    .snippet("SNIPPET")
    .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin)));

回答1:


I click a button (or something else) into the Infowindow to open a new activity (or a dialog) to show more information. Alternatively, I click a link into the Infowindow to open a webpage to show more information.

Neither of those are possible. However, you can detect a click on the whole info window via setOnInfoWindowClickListener(). Your onInfoWindowClick() method of your OnInfoWindowClickListener can then call startActivity(), show() a DialogFragment, etc.



来源:https://stackoverflow.com/questions/22348488/how-to-open-new-activity-or-dialog-or-link-from-a-infowindow-google-maps-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!