【发布时间】:2018-03-28 10:04:24
【问题描述】:
我在ConstraintLayout 中有一个RadioGroup。我有一个单选按钮列表(那些来自远程服务器调用)。所以单选按钮的数量不是固定的。有时它可以是 5 个,有时是 10 个或任何大小。我必须按列显示这些单选按钮,如下图所示。
我已经关注this 线程来动态添加单选按钮。我可以水平或垂直显示单选按钮。为了显示水平,我使用了以下代码:
healthCheckRadioGroup.setOrientation(LinearLayout.HORIZONTAL);
for(String healthPlan: healthCheckPlanList){
RadioButton radioButton = new RadioButton(getContext());
radioButton.setId(View.generateViewId());
radioButton.setText(healthPlan);
healthCheckRadioGroup.addView(radioButton);
}
上述代码的结果是一个单选按钮的水平列表。并且大多数按钮都超出了父布局(我的意思是不可见)
请帮我获取输出。谢谢。
【问题讨论】:
标签: android radio-button radio-group