To create a list of selectable items, the ListField class is needed and the ListFieldCallback interface must be implemented. ListField is the displayable field object and the ListFieldCallback interface is responsible for drawing the list elements to the screen. The ListFieldCallback drawListRow() method is called automatically by the system for each element in the list.
The following is a sample implementation of ListFieldCallback:
private class ListCallback implements ListFieldCallback { |
To create an instance of ListField
ListField _list = new ListField();
To create an instance of ListCallback, which is an implementation of the ListFieldCallback interface, use the following:
ListCallback _callback = new ListCallback();
After creating instances of ListField and ListCallback, an association between the two can be created by calling the ListField setCallback() method as follows:
_list.setCallback(_callback);
Now that the list has been initialized, items can be added to it as follows:
_list.insert(index);
_callback.insert(name, index);
Where name is the String that represents the name of the selectable item in the list and index is a number (int) that represents the position of the item in the list.
No comments:
Post a Comment
Place your comments here...