【发布时间】:2018-06-22 15:36:04
【问题描述】:
我是 Android 新手,尝试将 Text 设置为 RadioButtons。我正在使用 Hashmap 方法从列表字符串 (HashMap) 中获取值。我能够在日志视图中显示值,但无法将文本获取到 RadioButtons
请检查代码并提出解决方案
RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout);
radioGroup = new RadioGroup(this);
final RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
key = entry.getKey();
values = entry.getValue() != null;
System.out.println("Key = " + key);
System.out.println("Values = " + values + "n");
RadioButton radioButtonView = new RadioButton(this);
radioButtonView.setFreezesText(values);
radioGroup.addView(radioButtonView, p);
}
提前致谢
【问题讨论】:
-
检查这个例子stackoverflow.com/questions/6426317/…。它可以帮助你
-
我正在检查两个链接谢谢@Swarna
-
我正在检查链接@Ichigo Kurosaki
-
@Swarna 我可以在以前的项目中制作 RadioButtons 文本,但现在要求是 HashMap,我可以将值输入日志但不能在 RadioButtons 上
标签: java android hashmap radio-button