|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.lcdui.Item | +--javax.microedition.lcdui.ChoiceGroup
A ChoiceGroup is a group of selectable elements intended to be
placed within a Form
. The group may be created with a mode
that requires a single choice to be made or that allows multiple
choices. The implementation is responsible for providing the
graphical representation of these modes and must provide visually
different graphics for different modes. For example, it might use
"radio buttons" for the single choice mode and "check boxes" for the
multiple choice mode.
Note: most of the essential methods have been documented in the
Choice
interface.
Fields inherited from interface javax.microedition.lcdui.Choice |
EXCLUSIVE,
IMPLICIT,
MULTIPLE |
Constructor Summary | |
ChoiceGroup(String label,
int choiceType)
Creates a new, empty ChoiceGroup, specifying its title and its type. |
|
ChoiceGroup(String label,
int choiceType,
String[] stringElements,
Image[] imageElements)
Creates a new ChoiceGroup, specifying its title, its type, and an array of Strings and Images to be used as its initial contents. |
Method Summary | |
int |
append(String stringPart,
Image imagePart)
Appends an element to the Choice. |
void |
delete(int elementNum)
Deletes the element referenced by elementNum. |
Image |
getImage(int elementNum)
Gets the Image part of the element referenced by elementNum. |
int |
getSelectedFlags(boolean[] selectedArray_return)
Queries the state of a Choice and returns the state of all elements in the boolean array selectedArray_return. |
int |
getSelectedIndex()
Returns the index number of an element in the Choice that is selected. |
String |
getString(int elementNum)
Gets the String part of the element referenced by elementNum. |
void |
insert(int elementNum,
String stringPart,
Image imagePart)
Inserts an element into the Choice just before the element specified. |
boolean |
isSelected(int elementNum)
Gets a boolean value indicating whether this element is selected. |
void |
set(int elementNum,
String stringPart,
Image imagePart)
Sets the element referenced by elementNum to the specified element, replacing the previous contents of the element. |
void |
setSelectedFlags(boolean[] selectedArray)
Attempts to set the selected state of every element in the Choice. |
void |
setSelectedIndex(int elementNum,
boolean selected)
For MULTIPLE , this simply sets an individual element's
selected state. |
int |
size()
Gets the number of elements present. |
Methods inherited from class javax.microedition.lcdui.Item |
getLabel,
setLabel |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ChoiceGroup(String label, int choiceType)
label
- the item's label (see Item
)choiceType
- either EXCLUSIVE or MULTIPLEChoice.EXCLUSIVE
,
Choice.MULTIPLE
public ChoiceGroup(String label, int choiceType, String[] stringElements, Image[] imageElements)
The type must be one of EXCLUSIVE or MULTIPLE. The IMPLICIT choice type is not allowed for ChoiceGroup.
The stringElements array must be non-null and every array element must also be non-null. The length of the stringElements array determines the number of elements in the ChoiceGroup. The imageElements array may be null to indicate that the ChoiceGroup elements have no images. If the imageElements array is non-null, it must be the same length as the stringElements array. Individual elements of the imageElements array may be null in order to indicate the absence of an image for the corresponding ChoiceGroup element.
label
- the item's label (see Item
)choiceType
- EXCLUSIVE or MULTIPLEstringElements
- set of strings specifying the string parts of the
ChoiceGroup elementsimageElements
- set of images specifying the image parts of the
ChoiceGroup elementsChoice.EXCLUSIVE
,
Choice.MULTIPLE
Method Detail |
public int append(String stringPart, Image imagePart)
stringPart
- the string part of the element to be addedimagePart
- the image part of the element to be added, or
null if there is no image partpublic void delete(int elementNum)
elementNum
- the index of the element to be deletedpublic Image getImage(int elementNum)
elementNum
- the number of the elementChoice.getString(int)
public int getSelectedFlags(boolean[] selectedArray_return)
size()
. If the array is
longer, the extra elements are set to false.This call is valid for all types of Choices. For MULTIPLE, any number of elements may be selected and set to true in the result array. For EXCLUSIVE and IMPLICIT exactly one element will be selected (unless there are zero elements in the Choice).
selectedArray_return
- array to contain the resultspublic int getSelectedIndex()
For MULTIPLE, this always returns -1 because no single value can in general represent the state of such a Choice.
To get the
complete state of a MULTIPLE Choice, see getSelectedFlags
.
public String getString(int elementNum)
elementNum
- the index of the element to be queriedChoice.getImage(int)
public void insert(int elementNum, String stringPart, Image imagePart)
elementNum
- the number of the elementstringPart
- the string part of the element to be insertedimagePart
- the image part of the element to be inserted, or
null if there is no image partpublic boolean isSelected(int elementNum)
elementNum
- the index of the element to be queriedpublic void set(int elementNum, String stringPart, Image imagePart)
elementNum
- the index of the element to be setstringPart
- the string part of the new elementimagePart
- the image part of the element, or null if there
is no image partpublic void setSelectedFlags(boolean[] selectedArray)
For Choice objects of type MULTIPLE, this sets the selected state of every element in the Choice. An arbitrary number of elements may be selected.
For Choice objects of type EXCLUSIVE and IMPLICIT, exactly one array element must have the value true. If no element is true, the first element in the Choice will be selected. If two or more elements are true, the implementation will choose the first true element and select it.
selectedArray
- an array in which the method collects the
selection statuspublic void setSelectedIndex(int elementNum, boolean selected)
MULTIPLE
, this simply sets an individual element's
selected state.
For EXCLUSIVE
, this can be used only to select an
element, that is, the selected parameter must be true.
When an element is selected, the previously selected element is
deselected. If selected is false, this call is
ignored.
For IMPLICIT
, this can be used only to select an
element, that is, the selected parameter must be true.
When an element is selected, the previously selected element is
deselected. If selected is false, this call is ignored.
The call to setSelectedIndex does not cause implicit activation of a
Command
.
elementNum
- the index of the element, starting from zero.selected
- the new state of the element, where true means
selected, false means not selected.public int size()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |