3

Hey people? I have a challenge in getting the selected item from two RadionButtons (male and Female) using LWUIT on the J2ME platform.

RadioButton selected = genderGroup.getRadioButton(genderGroup.getSelectedIndex());
String selectedGender = selected.toString();

I tried the block of code above but never got what I expected.

Would someone please give me a hand.

Regards, Kevin.

bharath
  • 14,283
  • 16
  • 57
  • 95
kevintich
  • 51
  • 1
  • 6

2 Answers2

3

I suppose what you want to extract from the RadioButton is the text associated to this RadioButton. To do this you need to use getText() instead toString().

Is that what you want to do?

Mun0n
  • 4,438
  • 4
  • 28
  • 46
1

hey kevintich Please use This Code...

ComponentGroup radioGroup = new ComponentGroup();
final RadioButton defaultBorder = new RadioButton("Default");
radioGroup.addComponent(defaultBorder);
final RadioButton etchedBorder = new RadioButton("Etched Raised Theme");
radioGroup.addComponent(etchedBorder);
final RadioButton etchedColors = new RadioButton("Etched Raised Colors");
radioGroup.addComponent(etchedColors);
final RadioButton etchedLowBorder = new RadioButton("Etched Lowered Theme");
radioGroup.addComponent(etchedLowBorder);
final RadioButton etchedLowColors = new RadioButton("Etched Lowered Colors");
radioGroup.addComponent(etchedLowColors);
final RadioButton bevelBorder = new RadioButton("Bevel Raised Theme");
radioGroup.addComponent(bevelBorder);
final RadioButton bevelColors = new RadioButton("Bevel Raised Colors");
radioGroup.addComponent(bevelColors);
final RadioButton bevelLowBorder = new RadioButton("Bevel Lowered Theme");
radioGroup.addComponent(bevelLowBorder);
final RadioButton bevelLowColors = new RadioButton("Bevel Lowered Colors");
radioGroup.addComponent(bevelLowColors);
final RadioButton roundBorder = new RadioButton("Round Theme");
radioGroup.addComponent(roundBorder);
final RadioButton roundColors = new RadioButton("Round Colors");
radioGroup.addComponent(roundColors);
RadioButton disabledRadioButton = new RadioButton("Disabled Radio Button");
disabledRadioButton.setEnabled(false);
radioGroup.addComponent(disabledRadioButton);
f.addComponent(radioGroup);