Android OnTouch和OnTap重叠。怎么办?

Android OnTouch和OnTap重叠。怎么办?,android,Android,这是我的OnTouch代码。我有另一种显示弹出窗口的onTap方法。但是,它并没有被解雇,因为OnTouch与OnTap重叠。因此,如何将此OnTouchEvent函数转换为OnTap。因为,如果我删除这个onTouch函数,我将无法拖动标记 public boolean onTouchEvent(MotionEvent event, MapView mapView) { final int action=event.getAction(); final int x=(

这是我的OnTouch代码。我有另一种显示弹出窗口的onTap方法。但是,它并没有被解雇,因为OnTouch与OnTap重叠。因此,如何将此OnTouchEvent函数转换为OnTap。因为,如果我删除这个onTouch函数,我将无法拖动标记

 public boolean onTouchEvent(MotionEvent event, MapView mapView) {
final int action=event.getAction();
            final int x=(int)event.getX();
            final int y=(int)event.getY();
            boolean result=false;
            p =  map.getProjection().fromPixels(x, y);

            newP = p;
                  if (action==MotionEvent.ACTION_DOWN) {

                    for (OverlayItem item : items) {
                      Point pa=new Point(0,0);

                      map.getProjection().toPixels(item.getPoint(), pa);

                          //I maintain the hitTest's bounds so you can still
                          //press near the marker
                      if (hitTest(item, marker, x-pa.x, y-pa.y)) {
                        result=true;

                        inDrag=item;

                        items.remove(inDrag);
                        populate();

                            //Instead of using the DragImageOffSet and DragTouchOffSet
                            //I use the x and y coordenates from the Point
                        setDragImagePosition1(x, y);

                        dragImage.setVisibility(View.VISIBLE);

                        break;
                      }
                    }
                  }
                  else if (action==MotionEvent.ACTION_MOVE && inDrag!=null) {
                    setDragImagePosition1(x, y);

                    result=true;
                  }
                  else if (action==MotionEvent.ACTION_UP && inDrag!=null) {
                    dragImage.setVisibility(View.GONE);

                        //I get the geopoint without using any OffSet, directly with the 
                        //Point coordenates
                    p=map.getProjection().fromPixels(x,y);

                    OverlayItem toDrop=new OverlayItem(p, inDrag.getTitle(),
                                                       inDrag.getSnippet());
                    Drawable orig = inDrag.getMarker(0);

                        //In my case I had down heading Arrows as markers, so I wanted my 
                        //bounds to be at the center bottom
                    if( orig != null)
                        toDrop.setMarker(boundCenterBottom(orig));

                    items.add(toDrop);
                    populate();

                    inDrag=null;
                    result=true;
                  }


               return(result || super.onTouchEvent(event, mapView));



        }
        private void setDragImagePosition1(int x, int y) {
          RelativeLayout.LayoutParams lp=
            (RelativeLayout.LayoutParams)dragImage.getLayoutParams();

              //Instead of using OffSet I use the Point coordenates.
              //I want my arrow to appear pointing to the point I am moving, so 
              //I set the margins as the Point coordenates minus the Height and half the
              //width of my arrow.
          lp.setMargins(x-(dragImage.getWidth()/2),y-dragImage.getHeight(), 0, 0);


          dragImage.setLayoutParams(lp);
        }

在触发X次
onTouch
后,计算指针移动的平均距离。如果小于某个Y值,则启动
onTap
事件,否则开始拖动。

我有相同的问题,但仍然没有获得任何成功。您好。我解决了此问题,请参阅