当我在itemonsetchenge listner中取消选中复选框时,我想删除所有元素.这是我的代码
checkbox_timeslot.clear();
chk.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
String chetimeslot;
if(isChecked){
chetimeslot = (String)chk.getTag();
checkbox_timeslot.add(chetimeslot);
Log.e("array value", ""+checkbox_timeslot);
Log.e("checked slo value", ""+chetimeslot);
}else{
checkbox_timeslot.add("");
Log.e("else array value", ""+checkbox_timeslot);
}
}
});
Run Code Online (Sandbox Code Playgroud)
"checkbox_timeslot"是我的字符串数组list.i想要删除复选框中的元素是未选中的,并且从复选框列表中选中时添加项目.如何可能有帮助?
if(isChecked){
chetimeslot = (String)chk.getTag();
checkbox_timeslot.add(chetimeslot);
Log.e("array value", ""+checkbox_timeslot);
Log.e("checked slo value", ""+chetimeslot);
} else{
chetimeslot = (String)chk.getTag();
checkbox_timeslot.remove(chetimeslot);
Log.e("else array value", ""+checkbox_timeslot);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2567 次 |
| 最近记录: |