You can create a custom view by extending class View
or one of its subclasses, as we do with class CannonView
(Section 6.8), which extends SurfaceView
(discussed shortly). To add a custom component to a layout’s XML file, you must provide its fully qualified name (i.e., its package and class name), so the custom View
’s class must exist before you add it to the layout. We demonstrate how to create the CannonView
class and add it to a layout in Section 6.4.3.