How to create ChoiceGroup in Java ME
Article Metadata
This article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.
Reasons: hamishwillee (27 Sep 2012)
The article has no explanation of what it does other than the heading. It should be extended to state the type of choice group created, display and image and link to reference documentation. It should perhaps be merged with Choice group
Reasons: hamishwillee (27 Sep 2012)
The article has no explanation of what it does other than the heading. It should be extended to state the type of choice group created, display and image and link to reference documentation. It should perhaps be merged with Choice group
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class ChoiceMidlet extends MIDlet implements CommandListener {
Command exit = new Command("Exit", Command.EXIT, 1);
private Display display;
private boolean firsttime;
private Form form;
String[] stringArray = {"Choice A", "Choice B", "Choice C"};
public ChoiceMidlet() {}
protected void startApp() {
display = Display.getDisplay(this);
form = new Form("Choice Midlet");
ChoiceGroup[] groups = {
new ChoiceGroup("Exclusive",
ChoiceGroup.EXCLUSIVE, stringArray,null),
new ChoiceGroup("Multiple",
ChoiceGroup.MULTIPLE, stringArray,null),
new ChoiceGroup("Pop-Up",
ChoiceGroup.POPUP, stringArray,null)
};
for (int i = 0; i < groups.length; i++) {
form.append(groups[i]);
}
form.addCommand(exit);
form.setCommandListener(this);
display.setCurrent(form);
}
public void commandAction(Command c, Displayable d) {
if (c == exit) {
destroyApp(false);
notifyDestroyed();
}
}
protected void destroyApp(boolean unconditional) {}
protected void pauseApp() {}
}


(no comments yet)