private final RadioGroup rgAnswer;
bala bala...
for (int i = 0; i < qst.getOptions().size(); i++) {
RadioButton button = LayoutInflater.from(getContext())
.inflate(R.layout.exam_view_single_choice, rgAnswer, false)
.findViewById(R.id.rb_answer);
button.setText("index"+i);
button.setId(ID_INIT+i);
rgAnswer.addView(button, i);
}
rgAnswer.setOnCheckedChangeListener((radioGroup, i1) -> {
Log.e("TAG", "onCheckedChanged: "+ i1);
});
Android RadioGroup动态添加RadioButton
最新推荐文章于 2024-06-06 10:19:13 发布