The Basic Approach

Here is a high level overview of what you need to know to get started in creating your own View components:

1. Extend an existing View class or subclass with your own class.

2. Override some of the methods from the superclass. The superclass methods to override start with 'on', for example, onDrawQ, onMeasureQ, and onKeyDownQ. This is similar to the on... events in Activity or ListActivity that you override for lifecycle and other functionality hooks.

3. Use your new extension class. Once completed, your new extension class can be used in place of the view upon which it was based.

Tip: Extension classes can be defined as inner classes inside the activities that use them. This is useful because it controls access to them but isn't necessary (perhaps you want to create a new public View for wider use in your application).

0 0

Post a comment