I've got an ExpandableListView with my extended ExpandableListAdapter which contains my data (headers = ArrayList; childs = Hashmap).
My custom layout contains a TextView and a CheckBox, which can be toggled by clicking the child.
XML childView
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frag_search_item_layout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/vodka"
android:id="@+id/frag_search_item"
android:layout_margin="15dp"
android:layout_centerVertical="true"
android:textSize="18sp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frag_search_checkbox"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:gravity="center_vertical|center_horizontal"
android:layout_centerVertical="true"
android:focusable="false"/>
</RelativeLayout>
OnChildClickListener:
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
CheckBox check = (CheckBox) v.findViewById(R.id.frag_search_checkbox);
check.setChecked(!check.isChecked());
return false;
}
});
This is working fine but when I select a child, not only its CheckBox is toggled but also a random other CheckBox from another category of the ExpandableListView.
Here is an example: Example
When I click on "Vodka" not only the Vodka-CheckBox is toggled but also the Limettensaft-CheckBox. (Same when I uncheck the CheckBox)
I have not the slightest idea why this is happening but it totally screws up my results, since there are other methods triggered when a CheckBox is checked/unchecked.
Please Share Complete code
RépondreSupprimer