J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

ChoiceGroup

A ChoiceGroup displays several items which can be selected depending on it's choice type (either Choice.EXCLUSIVE, Choice.MULTIPLE or Choice.POPUP).
The ChoiceGroup in the screenshot below uses the exclusive-single-line view-type.

Design

A ChoiceGroup with a horizontal-choice view-type
The above design has been realized with these CSS settings:

.horizontalChoice {
	label-style: choiceGroupLabel;
	background-type: round-rect;
	background-color: focusedBgColor;
	include-label: true;
	layout: expand;
	view-type: horizontal-choice;
	horizontalview-left-arrow: url( arrow-left.png );
	horizontalview-right-arrow: url( arrow-right.png );
}

.horizontalChoice:hover {
	background-color: white;
}

.choiceItem {
	font-color: gray;
	font-style: bold;
	text-wrap: false;
}

.choiceItem:hover {
	font-color: black;
}

.choiceGroupLabel {
	font-style: italic;
	font-size: small;
	layout: newline-after;
}

ChoiceGroup CSS Attributes

Here's a list of all ChoiceGroup specific design attributes:

Choice Item CSS Attributes

Use the following CSS attributes for the styles of ChoiceGroup items:

Programming

Use ChoiceGroups normally in your programming:

//#style horizontalChoice
ChoiceGroup group = new ChoiceGroup("Limit search to:", ChoiceGroup.EXCLUSIVE, style );
//#style choiceItem
group.append( "All", null );
//#style choiceItem
group.append( "Events", null );
//#style choiceItem
group.append( "Concerts", null );
//#style choiceItem
group.append( "Cinema", null );
//#style choiceItem
group.append( "Plays", null );
form.append( group );

You can focus a ChoiceGroup item without selecting it by calling de.enough.polish.ui.UiAccess.focus( ChoiceGroup choiceGroup, int index ).

Configuration

You can configure if a List should not show commands like "Select" for implicit and exclusive Lists or "Mark" for multiple lists. By default such commands are shown. Specify these configuration settings in the variables section of your build.xml script.

Variable  DefaultValuesExplanation
polish.ChoiceGroup.suppressCommands false true, false Deactivates all commands.
<variable name="polish.ChoiceGroup.suppressCommands" value="true" />
polish.ChoiceGroup.suppressSelectCommand false true, false Deactivates the Select command for implicit and exclusive ChoiceGroups.
<variable name="polish.ChoiceGroup.suppressSelectCommand" value="true" />
polish.ChoiceGroup.suppressMarkCommands false true, false Deactivates the Mark/Unmark commands for multiple ChoiceGroups.
<variable name="polish.ChoiceGroup.suppressMarkCommands" value="true" />

You can also change or translate the default commands used in a ChoiceGroup with following settings in either messages.txt or using variables in your build.xml script. For more information about translations please refer to the localization section.

# text for the 'Select' command:
polish.command.select=Choose;
# texts for'Mark' and 'Unmark' commands:
polish.command.mark=Select
polish.command.unmark=Deselect

JavaDoc

back to top