
android 单选框动态渲染技术
对于从服务端动态获取枚举值的场景,为 radiogroup 动态渲染 radiobutton 有以下实现方法:
使用循环和 view.generateviewid():
RadioGroup radioGroup = findViewById(R.id.radioGroup);
for (String option : optionsFromServer) {
RadioButton radioButton = new RadioButton(this);
radioButton.setText(option);
radioButton.setId(View.generateViewId());
radioGroup.addView(radioButton);
}










