RadiobuttonField Super 带有标签、值和组

发布于 2024-11-01 03:00:33 字数 1227 浏览 4 评论 0原文

我是 Java 和 Blackberry 的新手,由于以下原因,我被困在注册屏幕上:

我有一个注册屏幕,其中显示 2 个单选按钮,男性和女性。只有这些“标签”不是由我编写的,它是我向网络服务请求的值和标签。 我需要的是这样的:

MyRadioButton rb1=(String label, String value, Group rbg);

它是 Super(label, value, group); ---这个值更多的是一个内部标签 ID,可以说是一个 pk_id.---

这样我就可以在之后检索选择了哪个 Rbutton 及其值,这样当我单击“注册”按钮时我可以将其发送回来。

我有一个如何执行此操作的示例,但不适用于黑莓:

Gender[] gender = WebServCall.GetUserGender();

    if (gender != null && gender.length == 2)
    {

        holder.radiob1.setText(gender[0].genderType);
        holder.radiob1.setTag(gender[0].PK_ID);
        holder.radiob2.setText(gender[1].genderType);
        holder.radiob2.setTag(gender[1].PK_ID);



    }
    else
    {
        //alert
    }
}

static class ViewHolder
{
    RadioButton radiob1;
    RadioButton radiob2;
}

(...)

//由用户获取插入的信息

... RadioButton register_buffer_Gender1 = (RadioButton) findViewById(R.id.radiob1); RadioButton register_buffer_Gender2 = (RadioButton) findViewById(R.id.radiob2);

... 布尔值 check1 = register_buffer_Gender1.isChecked(); 布尔值 check2 = register_buffer_Gender2.isChecked();

....

您能否举例说明如何做到这一点,但对于黑莓手机?

谢谢

I'm new to Java and Blackberry and i'm stuck with a registration screen, due to the fallowing:

I have a registration screen, where i show 2 radiobuttons, male and female. Only these 'labels' are not for me to write, it's a value and a tag that i request to a webservice.
What i needed was something like:

MyRadioButton rb1=(String label, String value, Group rbg);

and it's Super(label, value, group); ---this value more of an internal label ID, so to speak, a pk_id.---

so i could, after, retrieve which Rbutton was selected and it's value, so i could send it back when i click the Register Button.

I have an example of how to do it, but not for blackberry:

Gender[] gender = WebServCall.GetUserGender();

    if (gender != null && gender.length == 2)
    {

        holder.radiob1.setText(gender[0].genderType);
        holder.radiob1.setTag(gender[0].PK_ID);
        holder.radiob2.setText(gender[1].genderType);
        holder.radiob2.setTag(gender[1].PK_ID);



    }
    else
    {
        //alert
    }
}

static class ViewHolder
{
    RadioButton radiob1;
    RadioButton radiob2;
}

(...)

//Get the inserted information, by the user

...
RadioButton register_buffer_Gender1 = (RadioButton) findViewById(R.id.radiob1);
RadioButton register_buffer_Gender2 = (RadioButton) findViewById(R.id.radiob2);

...
boolean check1 = register_buffer_Gender1.isChecked();
boolean check2 = register_buffer_Gender2.isChecked();

....

Could you give and example of how to do this, but for blackberry?

Thank you

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

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

发布评论

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

评论(1

并安 2024-11-08 03:00:33

该方法实际上与 BlackBerry 开发非常相似:

//Setting up the buttons
RadioButtonGroup group = new RadioButtonGroup();

RadioButtonField radio1 = new RadioButonField(gender[0].genderType, group);
radio1.setCookie(gender[0].PK_ID);

RadioButtonField radio2 = new RadioButtoNField(gender[1].genderType, group);
radio2.setCookie(gender[1].PK_ID);

add(radio1);
add(radio2);

////////////////////////

//Retrieving info from the buttons
boolean check1 = radio1.isSelected();
boolean check2 = radio2.isSelected();

//or you can use the group
int checkedIndex = group.getSelectedIndex();

我建议查看 RadioButtonFieldRadioButtonGroup< /a>,应该可以让你上路。

The approach is actually pretty similar in BlackBerry development:

//Setting up the buttons
RadioButtonGroup group = new RadioButtonGroup();

RadioButtonField radio1 = new RadioButonField(gender[0].genderType, group);
radio1.setCookie(gender[0].PK_ID);

RadioButtonField radio2 = new RadioButtoNField(gender[1].genderType, group);
radio2.setCookie(gender[1].PK_ID);

add(radio1);
add(radio2);

////////////////////////

//Retrieving info from the buttons
boolean check1 = radio1.isSelected();
boolean check2 = radio2.isSelected();

//or you can use the group
int checkedIndex = group.getSelectedIndex();

I would suggest taking a look at the documentation on RadioButtonField and RadioButtonGroup, should get you on your way.

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