添加按钮映射信息窗口的android按钮、窗口、信息、android

2023-09-06 14:45:31 作者:我、只是个配角

在新的谷歌地图Android版API第2版,我可以很轻松地获得定制标记和信息窗口显示。不过,我想有我的信息窗口内的多个按钮,每执行一个不同的的onClick 的行动,但问题是,地图上把信息窗口,因为它是自己的按钮对象(无论我在哪里点击信息窗口时,presses整个事情)。有谁知道如何自定义这个有点多?

In the new Google Maps for Android API v2, I can very easily get custom markers and info windows to display. However, I'm trying to have multiple buttons inside of my info window, that each perform a different onClick action but the problem is, the map treats the InfoWindow as it's own button object (no matter where I click on the InfoWindow, it presses the entire thing). Does anyone know how to customize this a bit more?

推荐答案

刚刚发现这一点文档。

正如在信息窗口的previous部分,一个信息窗口   是不是活的视图,而该视图呈现为一个图像到   地图。这样一来,您对视图设置的任何监听器被忽略   你不能在各部分点击事件区分   风景。建议您不要将交互式组件 - 例如   如按钮,复选框或文本输入 - 在您的自定义信息   窗口。

As mentioned in the previous section on info windows, an info window is not a live View, rather the view is rendered as an image onto the map. As a result, any listeners you set on the view are disregarded and you cannot distinguish between click events on various parts of the view. You are advised not to place interactive components — such as buttons, checkboxes, or text inputs — within your custom info window.

不幸的是,回答它。我试图添加相同的功能你。

Unfortunately, that answers it. I was trying to add the same function as you.