Java Reference
In-Depth Information
Figure 5-8.
Various kinds of choices presented by the Choice and ChoiceGroup classes
Because the MIDP provides the
List
class—a class that presents choices—the MIDP
standard specifies the
Choice
interface, which is implemented by
ChoiceGroup
, an
Item
subclass, and the
Displayable
subclass
List
(which you'll see in the section “Creating a
Custom Item for a Screen” later in this chapter). Generally, you use a
ChoiceGroup
when
you want to mix choice items with other user-interface items. On the other hand, a
List
is best if the choices take up the entire display.
When you create a
ChoiceGroup
, you must also specify its type:
•
EXCLUSIVE
: The
ChoiceGroup
can have exactly one element selected at a time, but
multiple items may be shown.
•
MULITPLE
: The
ChoiceGroup
can have zero or more items selected at a time.
•
POPUP
: The
ChoiceGroup
can have exactly one element selected, and the selected
element is always shown.