嗨我在android中使用ExpandableListview。我的要求是,每次必須選擇一個組加上其子組(使用複選框)。如果我去另一個組,那麼以前選擇的組應該沒有選中。ExpandableListView複製複選框檢查
但是從我的代碼當我檢查第一組時會自動檢查最後一組。這是我的問題,下面是我的代碼。提前致謝。
listView.setOnGroupClickListener(新OnGroupClickListener(){
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
CheckBox last = holder.groupCHeck;
CheckBox current = (CheckBox) v
.findViewById(R.id.groupCheckBox);
last.setChecked(false);
current.setChecked(true);
if (listExpandedPosition.size() >= 1) {
if (listExpandedPosition.get(0) != groupPosition) {
listView.collapseGroupWithAnimation(listExpandedPosition
.get(0));
last.setChecked(false);
}
} else {
}
if (listView.isGroupExpanded(groupPosition)) {
listView.collapseGroupWithAnimation(groupPosition);
} else {
listView.expandGroupWithAnimation(groupPosition);
}
if (!listExpandedPosition.isEmpty())
listExpandedPosition.clear();
listExpandedPosition.add(groupPosition);
holder.groupCHeck = current;
return true;
}
});