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.
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;
}
});
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.