gpt4 book ai didi

java - 有没有办法显示未选择的单选按钮中的文本?

转载 作者:行者123 更新时间:2023-12-01 16:25:02 25 4
gpt4 key购买 nike

我正在 android 中工作,我想知道是否有一种方法可以将未选择的单选按钮中的文本附加到 TextView 上。作为一个看起来像“未选择:项目 A,项目 b”等的列表。

我想尝试这样的事情:

 if (radioButtonId == 1) {
notSelected.append(optionsContainer.getCheckedRadioButtonId(3).getText().toString());

但是我遇到了一个错误,内容为

getCheckedRadioButtonId() in RadioGroup cannot be applied to int()

任何帮助或建议将不胜感激。我什至不确定这是否可以做到

最佳答案

单选按钮一次只能选择一次,因此您无法“决定”要检查哪个索引。

getCheckedRadioButtonId()

返回实际选择的 View ID。

文档:

https://developer.android.com/reference/android/widget/RadioGroup#getCheckedRadioButtonId()

Returns the identifier of the selected radio button in this group. Upon empty selection, the returned value is -1.

正如我在评论中所说,请考虑阅读 https://stackoverflow.com/a/50955546/4628993

关于java - 有没有办法显示未选择的单选按钮中的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62164738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com