问题
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