I am c开发者_JAVA技巧urrently using pure OpenGL to paint buttons in my own little way.
I can detect if a button is pushed with onTouchEvent, but I want to know if the user is holding the button down, or if the user is no longer touching the screen.
After the initial MotionEvent.ACTION_DOWN event, all of the subsequent touch events(user keeps finger on the screen) will be MotionEvent.ACTION_MOVE events until the user lifts their finger off of the screen which will register as an MotionEvent.ACTION_UP event.
If you want to make sure the user still has their finger on the button do bounds checking during MotionEvent.ACTION_MOVE events or if you don't care if the user drags their finger off of the button just check for a MotionEvent.ACTION_UP event.
精彩评论