Catalogue
How to create a custom BlackBerry UI Field. 1
Directory... 2
An overview of ... 3
Two BlackBerry UI Field. 3
Three ways to create a custom UI field ... 3
3.1 Hyperlinkbuttonfield. 4
3.2 Bitmapbuttonfield and Mediacontrolstylefield. 8
3.3 Progressanimationfield. 10
Summary... 12
Reference... 12
an overview
The BlackBerry platform provides developers with a number of standard UI components, laying the groundwork for programmers to quickly develop mobile applications. But a lot of mobile software is consumer, entertainment software, these software needs to be unique, different, can seize the user's eye UI interface.
Standard UI components often fail to meet the unique requirements of developers and users, and many times developers need to use their imagination to create and customize new UI components. Fortunately, creating custom UI components above the BlackBerry platform is a simple matter. Two BlackBerry UI Field
From the BlackBerry API Java doc, we see our common UI components, such as text boxes ButtonField, LabelField, TextField and so on are all extensions to the Net.rim.device.api.ui.Field interface.
The more advanced BlackBerry UI components, such as Manager Manager and window screen, also inherit the field class.
Three ways To create a custom UI field
Create custom fields, write a field, and usually at least implement layout () and paint () two methods to set the field width and height to display the UI component's interface. Other options are as follows:
field is the smallest unit of the UI, and the smallest element cannot be placed in another field. Note: The manager class can be nested within the Manager and field classes, and the manager manages field placement on the screen. |
Extends field and implement the appropriate method. or extends existing field classes, such as LabelField, ListField |
field appears as a rectangular area on the phone screen, with width, height |
Implement layout (): Call the SetExtent () method to set the width and height of the field. |
Change the background in the field rectangle, display graphics/text, add borders, etc. |
Implement Paint (): Use methods such as the Drawtext,drawline,drawrect of a Graphics object to draw field |
field can choose whether to handle and how to handle keyboard/trackball events, such as the user pressed "BlackBerry exit key", you can choose to pop Up the dialog box dialog, let the user confirm the need to exit |
Implement Keychar (), Trackwheelclick (), invokeaction () and other methods. |
Field needs to tell the manager the width and height of its preferred so that the manager can control the display of each field |
Override Getpreferredwidth and Getpreferredheight methods |
When field is selected, on focus you can choose to redraw the fields. Note: The user wants the field check/unchecked state to display a different interface, such as the selection of high brightness display, plus a border, not selected to display the low brightness. |
Implement Drawfocus (): Use the Graphics Object SetBackgroundColor () method to change the background color, drawline,drawrect,drawtext and other methods to draw field |
field can choose whether to handle and how to handle the Focus/selected event |
Implement Onfocus () |
For details, see the original:
Http://images.csdn.net/upimgs/lee/BBPDF/RHCJDZDBBUIF.pdf