Java Reference
In-Depth Information
CHAPTER 6
■ ■ ■
Lists and Forms
I n the last chapter, you learned about MIDP's simpler screen classes. Now we're getting into
deeper waters, with screens that show lists and screens with mixed types of controls.
Using Lists
After TextBox and Alert , the next simplest Screen is List , which allows the user to select items
(called elements ) from a list of choices. A text string or an image is used to represent each element
in the list. List supports the selection of a single element or of multiple elements.
There are two main types of List , denoted by constants in the Choice interface:
MULTIPLE designates a list where multiple elements may be selected simultaneously.
EXCLUSIVE specifies a list where only one element may be selected. It is akin to a group of
radio buttons.
Understanding List Types
For both MULTIPLE and EXCLUSIVE lists, selection and confirmation are separate steps. In fact,
List does not handle confirmation for these types of lists—your MIDlet will need to provide
some other mechanism (probably a Command ) that allows users to confirm their choices. MULTIPLE
lists allow users to select and deselect various elements before confirming the selection. EXCLUSIVE
lists also permit users to change their minds several times before confirming the selection.
Figure 6-1a shows one implementation of an EXCLUSIVE list. With this list, the user navigates
through the list using the arrow up and down keys. An element can selected by pressing the
select button on the device. Figure 6-1b shows a MULTIPLE list. It works basically the same way
as an EXCLUSIVE list, but multiple elements can be selected simultaneously. As before, the user
moves through the list with the up and down arrow buttons. The select button toggles the
selection of a particular element.
A further refinement of EXCLUSIVE also exists: IMPLICIT lists combine the steps of selection
and confirmation. The IMPLICIT list acts just like a menu. Figure 6-2 shows an IMPLICIT list with
images and text for each element. When the user hits the select button, the list immediately
fires off an event, just like a Command . An IMPLICIT list is just like an EXCLUSIVE list in that the user
can only select one of the list elements. But with IMPLICIT lists, there's no opportunity for the
user to change his or her mind before confirming the selection.
67
Search WWH ::




Custom Search