更新#2 我有一个listView和适配器。 listView中的每个项目都有一个复选框。 当点击列表视图中的复选框时,下面的5-6项复选框(重复 - 所有复选框)也被按下 - 指示灯亮起,即使没有人点击,然后在检查它是否真正按下'isChecked'布尔标志,它是错误的。复选框在列表视图/适配器是“按”自己的
公共类watchAllAdapter扩展ArrayAdapter {
public watchAllAdapter(Context context, ArrayList<Subject> arrayList) {
super(context, 0, arrayList);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View listItemView = convertView;
if (listItemView == null) {
listItemView = LayoutInflater.from(getContext()).inflate(
R.layout.for_each_watch_all, parent, false);
}
final Subject currSubject = getItem(position);
final CheckBox cb = (CheckBox) listItemView.findViewById(R.id.checkbox_for_each);
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
if (isChecked){
currSubject.setChosen(true);
}
else{
cb.setChecked(false);
currSubject.setChosen(false);
}
}
});
return listItemView;
}
感谢=]
请在下面发布您的代码,以便我们可以检查它 –
是否做到了,谢谢您的回复,新的=]。 –