簡體   English   中英

在LWUIT中獲取所選的RadioButton

[英]Getting the selected RadioButton in LWUIT

嘿人? 我在J2ME平台上使用LWUIT從兩個RadionButtons (男性和女性)中獲取所選項目時遇到了挑戰。

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

我嘗試了上面的代碼塊,但從未達到我的預期。

有人請幫我一把。

問候,凱文。

我想你想從RadioButton提取的是與這個RadioButton相關聯的文本。 要做到這一點,你需要使用getText()而不是toString()

那是你想做的嗎?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM