O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

32Custom Views and Touch Events

In this chapter, you will learn how to handle touch events by writing a custom subclass of View named BoxDrawingView. This View will draw boxes in response to the user touching the screen and dragging.

Figure 32.1  Boxes drawn in many shapes and sizes

Boxes drawn in many shapes and sizes

Setting Up the DragAndDraw Project

The BoxDrawingView class will be the star of a new project named DragAndDraw. Select NewAndroid Application Project. Configure the project as shown in Figure 32.2. Then create a blank activity named DragAndDrawActivity.

Figure 32.2  Creating DragAndDraw

Setting up DragAndDrawActivity

DragAndDrawActivity will be a subclass of SingleFragmentActivity ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required