On Touch Event MotionEvent onTouchEvent basic Android sample code

boolean onTouchEvent(MotionEvent event) , PointF()

private final PointF mPointF = new PointF();
 
	        private int mLastWarpX = -9999; // don't match a touch coordinate
	        private int mLastWarpY;
 
	        @Override public boolean onTouchEvent(MotionEvent event) {
	            float[] pt = { event.getX(), event.getY() };
	            mPointF.set(event.getX(),event.getY());
 
	            int x = (int)pt[0];
	            int y = (int)pt[1];
	            if (mLastWarpX != x || mLastWarpY != y) {
	                mLastWarpX = x;
	                mLastWarpY = y;
	                // do something
	            }
	            return true;
	        } // END onTouchEvent
This entry was posted in Android Examples Code and tagged , , , , . Bookmark the permalink.


Comments are closed.

12,881 views