Reputation: 13329
This is what I have, I Expandable listview. Each Group item is a Checkbox witha Textview next to it.
I want that checkbox to be toggled checked/unchecked if the group is expanded or not expanded.
Also vica versa, so if the checkbox is checked, the list should be expanded etc.
Any ideas?
this is my group_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_channel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:focusable="false"
android:layout_gravity="left"
android:checked="false" />
<TextView
android:textSize="20sp"
android:textIsSelectable="false"
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="55dp"/>
</RelativeLayout>
It looks pretty, just need it to check and uncheck .
Upvotes: 0
Views: 728
Reputation: 13329
Ah ok, this is how i Did it
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,ViewGroup parent) {
View v;
if (convertView == null) {
v = newGroupView(isExpanded, parent);
} else {
v = convertView;
}
if ( isExpanded ) {
((CheckBox) v.findViewById(R.id.check_channel)).setChecked(true);
} else {
((CheckBox) v.findViewById(R.id.check_channel)).setChecked(false);
}
bindGroupView(groupPosition, isExpanded, v, parent);
return v;
}
Upvotes: 2