Overridden View Method onTouchEvent
Method onTouchEvent
(Fig. 7.28) is called when the View
receives a touch event. Android supports multitouch—that is, having multiple fingers touching the screen. At any time, the user can touch the screen with more fingers or remove fingers from the screen. For this reason, each finger—known as a pointer—has a unique ID that identifies it across touch events. We’ll use that ID to locate the corresponding Path
objects that represent each line currently being drawn. These Path
s are stored in pathMap
.
158 // handle touch event159 @Override160 public boolean onTouchEvent(MotionEvent event)161 {162 // get the event type and the ID of the pointer that caused the ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.