ExpandableListView and checkboxes
<p>I'm writing simple filter in Android and want to use <code>ExpandableListAdapter</code> with check boxes. </p>

<p>I have no problem with creating list or checking checkbox. but I really don't know how to remember choices. After closing group and opening again or when I try to open different group checkboxes are changes. </p>

<p>I tried to reading on the net about that but I didn`t find how to solve my problem. </p>

<p>Here is my code:</p>

<pre><code>public class TasksFilterDialog extends Dialog{

private static final String TAG = "Filter Dialog";
private static final String ChildID = "ChildID";
private static final String GroupID = "GroupID";

private boolean[] statusCheck;

ExpandableListView list;
SimpleExpandableListAdapter listAdapter;

public TasksFilterDialog(Context context) {
    super(context);
    statusCheck = new boolean[Tasks.Status.values().length];
    for(int i=0; i&lt;statusCheck.length; i++)
        statusCheck[i]=true;
}


@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "Creating dialog");
    this.setContentView(R.layout.tasks_filter);
    list = (ExpandableListView)findViewById(R.id.filter_list);
    setListAdapter();                       // Setting Adapter Values to use on list
    list.setAdapter(listAdapter);           // Setting creating adapter to list
    setOnChildClickListeners();         


    Log.d(TAG, "Creating dialog successfull");
}


private void setListAdapter() {
    Log.d(TAG, "Setting list adapter");
    listAdapter = new SimpleExpandableListAdapter(this.getContext(), 
            getGroups(), 
            R.layout.tasks_filter_groups_layout,  
            new String[] {GroupID}, 
            new int[] {R.id.filter_group_text}, 
            getChilds(), 
            R.layout.tasks_filter_simple_element, 
            new String[] {ChildID}, 
            new int[] {R.id.filter_simple_element_text});

    Log.d(TAG, "Setting list adapter successfull");
}

private List&lt;HashMap&lt;String, String&gt;&gt; getGroups() {
    Log.d(TAG, "Adding groups values");
    List&lt;HashMap&lt;String, String&gt;&gt; list = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
    HashMap&lt;String, String&gt; statusMap = new HashMap&lt;String, String&gt;();
    statusMap.put(GroupID, "Status");
    list.add(statusMap);
    HashMap&lt;String, String&gt; usersMap = new HashMap&lt;String, String&gt;();
    usersMap.put(GroupID, "Users");
    list.add(usersMap);
    Log.d(TAG, "Adding groups values successfull");
    return list;
}

private List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt; getChilds() {
    Log.d(TAG, "Adding childs values");
    List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt; list = new ArrayList&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt;();
    List&lt;HashMap&lt;String, String&gt;&gt; secList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
    HashMap&lt;String, String&gt; map;
    Tasks.Status status[] = Tasks.Status.values();
    for(int i=0; i&lt;status.length; i++) {
        Log.d(TAG, "Adding child" + status[i].toString());
        map = new HashMap&lt;String, String&gt;();
        map.put(ChildID, status[i].toString());
        secList.add(map);
    }
    list.add(secList);
    list.add(secList);
    Log.d(TAG, "Adding childs values succesfull");
    return list;
}

private void setOnChildClickListeners() {
    list.setOnChildClickListener(new OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView list, View v,
                int group, int id, long arg4) {
            CheckBox cb = (CheckBox) v.findViewById(R.id.filter_simple_element_check);
            cb.toggle();
            switch(group){
            case 0:
                if(statusCheck[id])
                    statusCheck[id]=false;
                else
                    statusCheck[id]=true;
                break;
            case 1:
                //TODO After getting Tasks function

            }
            return false;
        }

    });

}
</code></pre>

<p>}</p>
