Code example for MotionEvent

Methods: getActiongetPointerCountgetXgetY

0
		init(); 
	} 
	 
	@Override 
	public boolean onTouch(View v, MotionEvent event) {
		if (event.getPointerCount() < 2) {
			((EmotionInterface) getActivity()).setLeftRightScrollable(true);
			return false; 
		} 
 
		boolean isDown = event.getAction() == (MotionEvent.ACTION_POINTER_DOWN | 0x0100);
		boolean isUp = (event.getAction() == (MotionEvent.ACTION_POINTER_UP | 0x0100))
				|| (event.getAction() == MotionEvent.ACTION_CANCEL)
				|| (event.getAction() == (MotionEvent.ACTION_POINTER_UP | 0x0000));
 
		if (isDown) {
			((EmotionInterface) getActivity()).setLeftRightScrollable(false);
 
			X1 = event.getX(0);
			Y1 = event.getY(0);
			X2 = event.getX(1);
			Y2 = event.getY(1);
		} else if (isUp) {
			((EmotionInterface) getActivity()).setLeftRightScrollable(true);
			NX1 = event.getX(0);
			NY1 = event.getY(0);
			NX2 = event.getX(1);
			NY2 = event.getY(1);
			checkDistance(); 
		} 
 
		return false; 
	}