ChoiceGroup is broken on the Series 80 platform! This almost makes developing complex UI applications for this platform useless. To whit: if you add a ChoiceGroup to a form, your Command actions disappear. Here's a simple example:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ButtonTest extends MIDlet
implements CommandListener {
public static final Command EXIT_CMD = new Command("Exit",Command.EXIT,5);
public static final Command C1_CMD = new Command("No1",Command.SCREEN,1);
public static final Command C2_CMD = new Command("No2",Command.SCREEN,1);
public static final Command C3_CMD = new Command("No3",Command.SCREEN,1);
public static final Command C4_CMD = new Command("No4",Command.SCREEN,1);
TestForm form;
public ButtonTest() {
form = new TestForm("This is a test");
form.setCommandListener(this);
form.addCommand(C1_CMD);
form.addCommand(C2_CMD);
form.addCommand(C3_CMD);
form.addCommand(C4_CMD);
}
public void startApp() {
Display.getDisplay(this).setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean b) {
}
class TestForm extends Form {
public TestForm(String s) {
super(s);
StringItem stringitem = new StringItem("Hello World01","This is a Test");
append(stringitem);
ChoiceGroup choicegroup = new ChoiceGroup("Does this work?",ChoiceGroup.POPUP,new String[] { "Yes", "No" }, null);
append(choicegroup);
}
}
public void commandAction(Command c, Displayable d) {
System.out.println("Button Pressed");
}
}
You'll notice that this simple UI puts 4 commands on the form, right? Well, if you run it, ZERO commands are displayed on a platform 80 device. But if you comment out the "append(choicegroup)" the form is displayed correctly.
I've wasted two days tracking down this bug (Forum didn't help if you don't know what you're looking for)--and someone had reported a similar problem in DECEMBER! And still it's not fixed?!
I'm hoping someone else out there has run into this problem and found a suitable workaround. No, ChoiceGroup.EXCLUSIVE wouldn't help (it doesn't work anyway).

Reply With Quote

