Android ExpandableListView mit Single Choice CheckBox bei ChildView
Freunde,
Ich versuche, eine ExpandableListView zu schreiben, die bei ChildView Kontrollkästchen mit einfacher Auswahl verwendet. Und ich kann nicht verstehen, wie andere Kontrollkästchen in OnChildClickListener () von ExpandableListView auf "false" gesetzt werden. Hier ist mein Code:
ExpListView.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
CheckBox cb = (CheckBox) v.findViewById(R.id.checkbox);
if (cb.isChecked()) {
} else {
cb.setChecked(true);
//Here somehow I must set all other checkboxes to false.
//Is it possible?
}
return false;
}
});
Hier ist xml von ChildView:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textChild"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:textColor="@android:color/white"
android:layout_weight="1"
/>
<CheckBox android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:layout_gravity="right"
android:visibility="visible"
/>
</LinearLayout>