在LWUIT中获取选中的RadioButton

发布于 2024-12-10 05:32:59 字数 303 浏览 2 评论 0原文

嘿人们?我在 J2ME 平台上使用 LWUIT 从两个 RadionButton (男性和女性)获取所选项目时遇到了挑战。

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

我尝试了上面的代码块,但从未得到我所期望的结果。

有人可以帮我一下吗?

问候, 凯文.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失去的东西太少 2024-12-17 05:32:59

我想您想要从 RadioButton 中提取的是与此 RadioButton 关联的文本。为此,您需要使用 getText() 而不是 toString()

这就是你想做的吗?

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?

美羊羊 2024-12-17 05:32:59

嘿 kevintich 请使用此代码...

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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文