Ontouchevent () method
is to get a variety of actions on the screen, such as swipe left and right, click the Back button, and so on.
belongs to a macro screen touch monitor.
Ontouchlistener () method
is to get the click-Monitoring of a particular view of a control.
Official document: Http://developer.android.com/ref ... ntouchlistener.html
The two are easy to distinguish.
The difference is as follows:
1, if the Ontouch method return value in Setontouchlistener is True (the event is consumed), then the Ontouchevent method will not be executed;
2. The Ontouchevent method is executed only if the return value of the Ontouch method in Setontouchlistener is False (the event is not consumed and is passed down).
3. The above-mentioned situation applies to the View object (the event is first responded to by the topmost view object) instead of the ViewGroup object (the event is first responded to by the outermost view object).
In general terms:
Ontouchlistener's Ontouch method has a higher priority than ontouchevent, which is triggered first.
If the Ontouch method returns False, the ontouchevent is then triggered, and the Ontouchevent method is not invoked.
Built-in implementations such as the Click event are based on Ontouchevent, and if Ontouch returns True, these events will not be triggered.
The difference between Android ontouchevent and Setontouchlistener in Ontouch