Home > Mobile > Android the same button can set a touch to monitor and a click to monitor events??
Android the same button can set a touch to monitor and a click to monitor events??
Time:10-05
The same button can set a touch to monitor and a click to monitor events? If you can how should I deal with the relationship between the two?
CodePudding user response:
Can look at the controls of OnTouchListener The button.. SetOnTouchListener (new the OnTouchListener () { @ Override Public Boolean the onTouch (View v, MotionEvent event) { return false; } }); As well as the type MotionEvent events
CodePudding user response:
Can ah, I was doing so, to touch to change font color, click click execution time, touch not click, because when finger according to move to the outside of the button to lift will not implement the click event,
nextButton. SetOnTouchListener (new the OnTouchListener () { @ Override Public Boolean the onTouch (View v, MotionEvent event) { If (nextButton isEnabled ()) { If (event. GetAction ()==MotionEvent. ACTION_DOWN) { Xff000000 nextButton. SetTextColor (0); } else if (event. GetAction ()==MotionEvent. ACTION_UP | | event. The getAction ()==MotionEvent. ACTION_CANCEL) { NextButton. SetTextColor (0 XFFFFFFFF); } } return false; } }); NextButton. SetOnClickListener (new View. An OnClickListener () { @ Override Public void onClick (View v) {