我试图在地图覆盖上放置一个标记,然后在用户选择drawable时显示一个对话框.问题是事件似乎重叠.单击地图并绘制标记后,onTap会立即触发,因为我刚刚绘制了标记,它直接位于onTap事件下,因此我的对话框始终会触发.有没有人对如何使这些事件互相排斥?
以下是地图活动的代码:
public class SelectGameLocation extends MapActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
private MapView mapView = null;
private SelectGameLocationItemizedOverlay selectLocationOverlay = null;
private List<Overlay> mapOverlays = null;
private GestureDetector gestureDetector = null;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
//set the layout
setContentView(R.layout.activity_select_game_location);
//configure activity for double clicks
gestureDetector = new GestureDetector(this);
gestureDetector.setOnDoubleTapListener(this);
//create and configure mapview
mapView = (MapView) findViewById(R.id.selectGameLocation);
mapView.setBuiltInZoomControls(true);
mapView.setHapticFeedbackEnabled(true);
//configure the overlay to draw the icons on the map
mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.map_icon);
selectLocationOverlay …Run Code Online (Sandbox Code Playgroud)