Code example for MotionEvent

Methods: getXgetY

0
    private void activateScaleDetector(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
    } 
 
    private void updateXYPositionSimpleTouch(MotionEvent ev) {
        mLastTouchX = ev.getX();
        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);
        }