【发布时间】:2011-12-13 07:52:00
【问题描述】:
我有一个 TableLayout,我正在动态添加行。在每一行,我也有一个复选框。
我的问题是控制哪些复选框被选中,我什至不知道如何循环每一行。请帮帮我。
【问题讨论】:
标签: android checkbox dynamic tablelayout
我有一个 TableLayout,我正在动态添加行。在每一行,我也有一个复选框。
我的问题是控制哪些复选框被选中,我什至不知道如何循环每一行。请帮帮我。
【问题讨论】:
标签: android checkbox dynamic tablelayout
Checkbox checkbox;
checkbox = (CheckBox) findViewById(R.id.checkbox);
checkBox.setChecked(false);
还是真的。应该可以,只需将复选框替换为您的变量和@+id
编辑:
你可以实现 OnCheckedChangeListener,然后使用类似的东西
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
switch (arg0.getId()) {
case R.id.checkbox1:
if (checkbox1.isChecked()){
//code to use when user checks the box
}else{
//code to use when user UNchecks the box
}
break;
}
}
【讨论】: