我以编程方式将RadioButtons添加到RadioGroup,并使用getCheckedRadioButtonID()
获取已检查的RadioButton Id。如果我重新访问具有RadioButtons的片段页面,尽管在RadioGroup中使用了removeAllViews(),但RadioButton ID的数量仍会增加。似乎removeAllViews()
删除了所有子视图,但它没有重置RadioButton ID。有没有办法重置RadioButtonID?
答案 0 :(得分:0)
Provide the id and don't let it be by default. If you use a for cycle, just do something like this:
rb.setId(i);