Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends Activity {
- ...
- // This example shows an Activity, but you would use the same approach if
- // you were subclassing a View.
- @Override
- public boolean onTouchEvent(MotionEvent event){
- int action = MotionEventCompat.getActionMasked(event);
- switch(action) {
- case (MotionEvent.ACTION_DOWN) :
- Log.d(DEBUG_TAG,"Action was DOWN");
- return true;
- case (MotionEvent.ACTION_MOVE) :
- Log.d(DEBUG_TAG,"Action was MOVE");
- return true;
- case (MotionEvent.ACTION_UP) :
- Log.d(DEBUG_TAG,"Action was UP");
- return true;
- case (MotionEvent.ACTION_CANCEL) :
- Log.d(DEBUG_TAG,"Action was CANCEL");
- return true;
- case (MotionEvent.ACTION_OUTSIDE) :
- Log.d(DEBUG_TAG,"Movement occurred outside bounds " +
- "of current screen element");
- return true;
- default :
- return super.onTouchEvent(event);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement