Developers
Local Navigation
Exercise
Create an application that displays a sequence of complex records in a grid with selectable rows.
Prerequisite: You should have completed the lab entitled Introduction to User Interface managers before starting this exercise.
Objectives
- Apply your understanding of managers in building a useful custom UI component.
- Discover how to use a ListField and ListFieldCallback for showing a sequence of selectable items.
- Discover how to manipulate a Graphics context.
- Experience some uses of BitmapField, NullField and DateField.
Setup
- Download the file (ZIP)
- In the IDE, open the table_list_field.jdw workspace
- Open the TableListApp.java source file.
- Open the TableListField.java source file.
Tasks
- Create a row manager for each row that is to be the content of a newly-created TableListField.
- Set the size and callback of the newly-created TableListField.
- Implement getColumnStart to calculate the horizontal position at which a given column should begin.
- When a TableRowManager is called upon to draw a row, transform and restore the Graphics context before and after the call to paint, so that the row paints into the correct region.
- Complete the sublayout, getPreferredWidth, and getPreferredHeight methods of the TableRowManager.
- When the framework invokes the RENDERER callback to draw a row from a list, have the RENDERER delegate to the proper TableRowManager.
- Within the TableListApp constructor, instantiate appropriate tableContent fields to represent the FAKE_DATA array.
- Within the TableListApp constructor, create the table and add it to the screen.
Check Your Work
Download the completed code (ZIP)
Review
In this exercise, you discovered the following things:
- how to build a custom UI component.
- to use a ListField and ListFieldCallback for showing a sequence of selectable items.
- to manipulate a Graphics context.
- some uses of BitmapField, NullField and DateField.
Additional Labs
Go to the first exercise in “Connecting to Email, Calendar and PIM Applications on BlackBerry”, Sending email messages