我想在点击地图上的标记时显示一个对话框。我可以在地图上设置标记,但我无法弹出对话框,该对话框应包含有关标记地点的一些描述。我尝试覆盖 onTouchEvent(),但只有在点击确切点时才会出现该框。但我想要的是在触摸标记内的任何点时显示对话框。有人可以帮我吗?
谢谢。
在这种情况下,我有类扩展 ItemizedOverlay 你只是覆盖 onTap
public class PlaceItemizedOverlay extends ItemizedOverlay<OverlayItem> {
@Override
protected boolean onTap(final int index) {
final OverlayItem oi = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle("your title");
dialog.setMessage("youmessage");
dialog.setNegativeButton("Cancel", null);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
dialog.show();
return true;
}
}
您可以使用或参考 MapViewBalloons 项目
您可以在 Handler 类的帮助下为此显示一个 AlertDialog。请在此处查看我的答案。