Code example for MotionEvent

Methods: getActiongetPointerIdgetXgetY

0
        mLastTouchY = ev.getY();
 
    } 
 
    private void updatePointerId(MotionEvent ev) {
        final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
        final int pointerId = ev.getPointerId(pointerIndex);
        if (pointerId == mActivePointerId) {
            // This was our active pointer going up. Choose a new 
            // active pointer and adjust accordingly. 
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mLastTouchX = ev.getX(newPointerIndex);
            mLastTouchY = ev.getY(newPointerIndex);
            mActivePointerId = ev.getPointerId(newPointerIndex);
        } 
    } 
 
    @Override 
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);