单选按钮没有突出显示,就像它们被选中一样

发布于 2024-08-30 19:30:59 字数 295 浏览 1 评论 0原文

我正在开发一个带有包含 10 个 RadioButtons 的 RadioGroup 的 Android 活动。有时出于某种原因,仅有时,当您在 RadioGroup 中选择 RadioButton 时,它不会突出显示,就像它已被选中一样,但通过一些测试,我确定它确实已被选中,即使它没有突出显示。发生的另一件奇怪的事情是,当您选择 RadioGroup 中的任何其他 RadioButton,然后尝试选择原始的 Radio Button(不会突出显示的单选按钮,就像它被选中一样)时,它会突出显示并正常运行。

知道为什么会发生这种情况或如何解决它吗? 谢谢!

I'm working on an android activity with a RadioGroup containing 10 RadioButtons. For some reason or another sometimes, only sometimes, when you select a RadioButton in the RadioGroup it doesn't highlight as if it's selected but through some tests I've determined that it really IS selected even though it isn't highlighted. Another odd thing that occurs is that when you select any other RadioButton in the RadioGroup and then try selecting your original Radio Button (the one that wouldn't highlight as though it were selected) it does highlight and functions as normal.

Any idea why this is happening or how to fix it?
Thanks!

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

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

发布评论

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

评论(2

痞味浪人 2024-09-06 19:30:59

不要设置单独的RadioButton.setSelected(false),而是使用RadioGroup.clearCheck()。这对我有用:-)

Instead of setting individual RadioButton.setSelected(false), Use RadioGroup.clearCheck(). This worked for me :-)

坦然微笑 2024-09-06 19:30:59
RadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
            public void onCheckedChanged(RadioGroup grp,int checkedId){
    int selected = RadioGroup.getCheckedRadioButtonId();
    RadioButton b = (RadioButton) findViewById(selected);
}
});

使用这个概念来提取选中的单选按钮的正确值。

RadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
            public void onCheckedChanged(RadioGroup grp,int checkedId){
    int selected = RadioGroup.getCheckedRadioButtonId();
    RadioButton b = (RadioButton) findViewById(selected);
}
});

Use this concept for extracting the correct value of checked radiobutton.

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