How to detect one finger and two finger tap in android & also a ACTION_MOVE?

时间:2015-10-06 08:49:56

标签: android touch mouseevent mouse

public boolean onTouchEvent(MotionEvent event) {
    float x=event.getX()*2;
    float y=event.getY()*2;
    tv1.setText(String.valueOf(x));
    tv2.setText(String.valueOf(y));


    try {
        out = new PrintWriter(ClientSocket.getOutputStream(),true);
    switch(event.getAction()&MotionEvent.ACTION_MASK){
        case MotionEvent.ACTION_MOVE:
                out.println("x:"+x*2);
                out.println("y:"+y*2);
             break;

        case MotionEvent.ACTION_POINTER_DOWN:
            int tap=event.getPointerCount();
            int index=event.getActionIndex();
            Log.d("cv", String.valueOf(tap));
            if(tap==2){
                Toast.makeText(this,"Two Finger",Toast.LENGTH_SHORT).show();
                out.println("rightclick");

            }
            break;
    }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return super.onTouchEvent(event);

}

This is the code which I using so far but it give only two finger tap & ACTION_MOVE event but I also want to detect one finger tap without interfering the ACTION_MOVE event. So please help me fast....

0 个答案:

没有答案