Reputation: 53
There is an extended SurficeView class that I want that while the user is touching the screen (like onKeyDown) it does something.
Like this:
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.e("Touching", "Touching the Screen");
return true;
}
While the user is touching the screen I want my LogCat to be spammed (just testing) 'til I'm not touching it but it only shows the message twice: when I touch and when I release.
Upvotes: 0
Views: 1473
Reputation: 5784
Here is Different Behavour of OnTouch Listener
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(TAG, "mode=DRAG");
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
Log.i("Tag", "1");
break;
case MotionEvent.ACTION_POINTER_DOWN:
Log.i("Tag", "2");
break;// return
case MotionEvent.ACTION_UP:
Log.i("Tag", "3");
case MotionEvent.ACTION_POINTER_UP:
Log.i("Tag", "4");
break;
case MotionEvent.ACTION_MOVE:
Log.i("Tag", "5");
break;
}
return true;
}
});
Upvotes: 1
Reputation: 3633
write Log in one of below actions like:
@Override
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction==MotionEvent.ACTION_DOWN){
Log.e("Touching", "Touching the Screen");
}
else if(event.getAction==MotionEvent.ACTION_UP){
Log.e("Touching up", "Touching the Screen up");}
return true;
}
Upvotes: 0