我在安卓系统中工作,我想知道是否有一种方法可以将未选中的单选按钮的文本添加到TextView中。作为一个看起来像“未被选中:项A,项b”等的列表。
我想试一下这样的东西:
if (radioButtonId == 1) {
notSelected.append(optionsContainer.getCheckedRadioButtonId(3).getText().toString());
但是我看到了一个错误,如下所示
getCheckedRadioButtonId() in RadioGroup cannot be applied to int()
任何帮助或建议都将不胜感激。我甚至不确定这是不是可以做的事情
发布于 2020-06-03 11:48:25
RadioButtons可以一次选择一次,所以你不能“决定”你想要检查哪个索引。
getCheckedRadioButtonId()
返回实际选中的视图id。
文档:
https://developer.android.com/reference/android/widget/RadioGroup#getCheckedRadioButtonId()
返回该组中选定单选按钮的标识符。选择为空时,返回值为-1。
正如我在评论中所说的,请考虑阅读https://stackoverflow.com/a/50955546/4628993
https://stackoverflow.com/questions/62164738
复制相似问题