Chapter 13. Handling Input and Scrolling
In the previous chapter, “Developing Custom Views,” you worked through how to create a custom view that properly handles measurement, layout, drawing, and saving/restoring state. Now it’s time to round out that knowledge with a deep look at handling input and scrolling.
Touch input is the primary means of interacting with views in Android. In most cases, you can use the standard listeners, such as
OnLongClickListener, to handle the interactions. In some cases, you need to handle custom, more complex touches. If a view already meets your needs but you just need to handle custom touches, then consider using the
OnTouchListener to avoid having to subclass the view.