fazlurr
11/13/2014 - 12:14 PM

Android - Touch Listener

Android - Touch Listener

rootView.setOnTouchListener(new OnTouchListener() {
		    public boolean onTouch(View v, MotionEvent event) {
		        // Respond to touch events
		    	int action = MotionEventCompat.getActionMasked(event);
		        
		        switch(action) {
		            case (MotionEvent.ACTION_DOWN) :
		                Log.v("Gesture","Action was DOWN");
		                return true;
		            case (MotionEvent.ACTION_MOVE) :
		            	Log.v("Gesture","Action was MOVE");
		                return true;
		            case (MotionEvent.ACTION_UP) :
		            	Log.v("Gesture","Action was UP");
		                return true;
		            case (MotionEvent.ACTION_CANCEL) :
		            	Log.v("Gesture","Action was CANCEL");
		                return true;
		            case (MotionEvent.ACTION_OUTSIDE) :
		            	Log.v("Gesture","Movement occurred outside bounds " +
		                        "of current screen element");
		                return true;      
		            default :
//		                return super.onTouchEvent(event);
		            	return true;
		        }
		    }
		});