Even though I’m newbie with Android I’m feeling more noob than ever.
I have my view that extends SurfaceView, and there I override the onTouchEvent and put this testing code inside:
if (event.getAction() == MotionEvent.ACTION_MOVE)
{
return true;
}
return false;
Then when I run the application in the emulator (using Eclipse) in debugging mode, there’s no way I can make it return true. I click, keep clicked and drag, and then release, but it will always be event.getAction == 0 no matter what.
What am I missing?
getAction()returns a combination of the actual action flag and the index of the pointer that generated that event (used for multitouch).To have only the action part you can do an AND with
MotionEvent.ACTION_MASK:or if you’re on API >= 8 you can directly use
getActionMasked(). This is useful if you have to test it in aswitch.similar question here