有谁知道如何使用 android 2.1 创建一个带有 2 个按钮的消息气泡出现在地图应用程序的覆盖项目顶部?
我目前已经实现了一个覆盖项目,它在 Android 的地图应用程序上显示地理点的图标。单击该图标时,它会从下面的 onTap
方法中调出一个 AlertDialog
。我有以下问题:
- 有谁知道如何在图标覆盖项正上方显示地图消息气泡,并带有 2 个标注按钮,一个位于标题左侧,一个位于气泡右侧?
- 有谁知道如何使覆盖项目可拖动,以便我可以按住它并将其拖动到地图上。我正在尝试复制 iPhone 上可用的可拖动图标行为。
如果是这样,请分享一些示例代码。谢谢
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
I currently have implemented an overlay item that shows an icon for Geo-point on a map application in Android. When the icon is clicked, it brings up an AlertDialog
from the onTap
method below. I have the following questions:
- Does anyone know how to display a map message bubble directly above the icon overlayitem with 2 callout buttons one to the left of the title and one to the right of the bubble?
- Does anyone know how to make the overlayitem draggable so I can press and hold it and drag it across the map. I am trying to duplicate the draggable icon behaviour that's available on the iPhone.
If so, please share some sample code. Thanks
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
至于#1,您可以在 this 中查看如何创建弹出面板我的一本书中的示例项目。
至于#2,严格来说我不认为这是可能的。当然,至少我见过,没有任何内置的东西可以做到这一点。您可以尝试检测触摸事件,删除现有的覆盖项目,在覆盖项目所在的位置绘制自己的图标副本,在用户拖动时手动设置动画,然后将覆盖项目放在用户放置的位置(摆脱你手动绘制的图标)。
As for #1, you can see how to create popup panels in this sample project from one of my books.
As for #2, I do not believe it is possible, strictly speaking. Certainly, there is nothing built in for that, at least that I have seen. You could attempt to detect a touch event, get rid of the existing overlay item, draw your own copy of the icon where the overlay item had been, manually animate that as the user drags, and then put the overlay item where the user drops it (getting rid of your manually-drawn icon).