Code example for MotionEvent

Methods: getActiongetXgetYsetLocation

0
     * {@hide} 
     */ 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        if (isLeftSideOpened()) { 
            return mLeftDragAction.onTouchEvent(ev);
        } else if (isRightSideOpened()) { 
            return mRightDragAction.onTouchEvent(ev);
        } else { 
            return true; 
        } 
    } 
 
    private class BehindLinearLayout extends LinearLayout {
 
        public BehindLinearLayout(Context context) {
            super(context);
        } 
         
        /** 
         * Adjust the behind view 
         * @param rect The display area 
         */ 
        public void fitDisplay(Rect rect) {
            mBehindView.setPadding(rect.left, rect.top, 0, 0);
            requestLayout();
        } 
    } 
     
    /** 
     * Overlay view only when the behind menu is appeared. 
     * This view control scrolling the above view   
     * @author Masahiko Adachi 
     */ 
    private class OverlayView extends View {
        private static final float CLICK_RANGE = 3;
        private float mDownX;
        private float mDownY;
        private OnClickListener mClickListener;
        public OverlayView(Context context) {
            super(context);
        } 
         
        public void setOnClickListener(OnClickListener listener) {
            mClickListener = listener;
            super.setOnClickListener(listener);
        } 
         
        public boolean onTouchEvent(MotionEvent ev) {
            ev.setLocation(ev.getX() - mAboveView.getScrollX(), 0);
            SimpleSideDrawer.this.onTouchEvent(ev);
            int action = ev.getAction() & MotionEvent.ACTION_MASK;
                float x = ev.getX();
                float y = ev.getY();
            if (action == MotionEvent.ACTION_DOWN) {
                mDownX = x;
                mDownY = y;
            } else if (action == MotionEvent.ACTION_UP) {
                if (mClickListener != null) {