Responding to Touch
Android works on a variety of devices, so it has methods to gather all types of input. For you, however, the most important events are interactions with the touchscreen. Your number-one method is the following:
Public boolean onTouchEvent(MotionEvent event){
}
This method is inherited from the View
class, and you override it in order to perform your own operations. The key aspect of this function is the parameter it contains. A MotionEvent
is an object in Android that describes a variety of interactions with the tablet. You can find out a lot about the event by calling methods in the MotionEvent
class. This class has many options, but the important functions are pointed out as you use them. If you’re curious, you can look ...
Get Beginning Android Tablet Games Programming 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.