Java Android最后一个复选框与其他复选框连接
我已经动态创建了一个复选框列表,问题是 示例:我有以下复选框 检查1[]检查2[]检查3[]检查4[]检查5[] 现在,如果单击“检查1”,则“检查5”现在处于选中状态 与检查2、3、4相同。 如果单击“检查5”,则仅单击“检查5” 但是,当我选中复选框的IsChecked()状态时,只有单击的复选框为true(即使复选框显示图形,也不选中5,除非我实际单击了它) 反之亦然,如果我取消选中check1,则取消选中check5Java Android最后一个复选框与其他复选框连接,java,android,checkbox,Java,Android,Checkbox,我已经动态创建了一个复选框列表,问题是 示例:我有以下复选框 检查1[]检查2[]检查3[]检查4[]检查5[] 现在,如果单击“检查1”,则“检查5”现在处于选中状态 与检查2、3、4相同。 如果单击“检查5”,则仅单击“检查5” 但是,当我选中复选框的IsChecked()状态时,只有单击的复选框为true(即使复选框显示图形,也不选中5,除非我实际单击了它) 反之亦然,如果我取消选中check1,则取消选中check5 LinearLayout linearChildren = (
LinearLayout linearChildren = (LinearLayout) findViewById(R.id.linEvents);
Resources res = getResources();
Drawable checkbox = res.getDrawable(R.drawable.custom_checkbox_design);
for (int count = 0; count < numberOfEvents; count++) {
CheckBox event = new CheckBox(ActivityAttend.this);
event.setText(todaysEvents.get(count).getEventName());
event.setButtonDrawable(checkbox);
linearChildren.addView(event);
}
LinearLayout linearChildren=(LinearLayout)findViewById(R.id.linEvents);
Resources res=getResources();
Drawable checkbox=res.getDrawable(R.Drawable.custom\u checkbox\u design);
for(int count=0;count
这是我用setButtonDrawable做的事吗?还是我完全遗漏了一些明显的东西?在您的迭代中,您一直在使用相同的可绘制复选框。若要修复它,请将您的牵引装置移动到for循环中
LinearLayout linearChildren = (LinearLayout) findViewById(R.id.linEvents);
Resources res = getResources();
for (int count = 0; count < numberOfEvents; count++) {
Drawable checkbox = res.getDrawable(R.drawable.custom_checkbox_design);
CheckBox event = new CheckBox(ActivityAttend.this);
event.setText(todaysEvents.get(count).getEventName());
event.setButtonDrawable(checkbox);
linearChildren.addView(event);
}
LinearLayout linearChildren=(LinearLayout)findViewById(R.id.linEvents);
Resources res=getResources();
for(int count=0;count
尝试将您的第三行移动到for循环中。然后我会将其作为答案发布:)