Android 单个onTouch检测到4个事件?

Android 单个onTouch检测到4个事件?,android,Android,按钮通过onDraw在画布上绘制。在下面的方法中,我得到了绘制的按钮的位置,并检测到其中的触摸。一旦检测到snapShot()被调用。我已经替换了snapShot()的内容。每次触摸我都会打印出四行。我不明白这个方法是如何连续多次调用snapShot()的 public boolean onTouch(View view, MotionEvent me) { Resources res = getResources(); Bitmap bitmap = BitmapFactory

按钮通过
onDraw
在画布上绘制。在下面的方法中,我得到了绘制的按钮的位置,并检测到其中的触摸。一旦检测到
snapShot()被调用。我已经替换了
snapShot()的内容System.out.println(“调用snapShot()”)进行编码>。每次触摸我都会打印出四行。我不明白这个方法是如何连续多次调用snapShot()的

public boolean onTouch(View view, MotionEvent me) {
    Resources res = getResources();
    Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.camera);
    DisplayMetrics metrics = getResources().getDisplayMetrics();
        int w = metrics.widthPixels;
        int h = metrics.heightPixels;
        int heightOffset = - bitmap.getHeight() + h;
        int widthOffset = w - bitmap.getWidth();
    //See if the motion event is on a Marker
     if((me.getRawX() >= widthOffset && me.getRawX() < (widthOffset + bitmap.getWidth()) 
                && me.getRawY() >= heightOffset && me.getRawY() < (heightOffset + bitmap.getHeight()))) 
        {
            snapShot();
            return true; 

    }

    return super.onTouchEvent(me);
};
public boolean onTouch(视图、运动事件me){
Resources res=getResources();
位图位图=位图工厂.decodeResource(res,R.drawable.camera);
DisplayMetrics=getResources().getDisplayMetrics();
int w=度量值。宽度像素;
int h=metrics.heightPixels;
int heightOffset=-bitmap.getHeight()+h;
int-widthOffset=w-bitmap.getWidth();
//查看运动事件是否位于标记上
如果((me.getRawX()>=widthOffset&&me.getRawX()<(widthOffset+bitmap.getWidth())
&&me.getRawY()>=heightOffset和&me.getRawY()<(heightOffset+bitmap.getHeight())
{
快照();
返回true;
}
返回super.onTouchEvent(我);
};

因为当手指向下、移动和抬起时,都会调用onTouch。您需要检查MotionEvent以确定手指在做什么。在不引起移动事件的情况下触摸也可能非常困难-请参见触摸斜坡