About checkbox as child in ExpandableList

Put your problem here if it does not fit any of the other categories.

About checkbox as child in ExpandableList

Postby chisheng » Thu Dec 24, 2009 5:02 am

Code: Select all
package com.example.android.apis.view;

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.SimpleExpandableListAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Demonstrates expandable lists backed by a Simple Map-based adapter
*/
public class ExpandableListTest extends ExpandableListActivity {
    private static final String NAME = "NAME";
   
    private ExpandableListAdapter mAdapter;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
        List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
        for (int i = 0; i < 20; i++) {
            Map<String, String> curGroupMap = new HashMap<String, String>();
            groupData.add(curGroupMap);
            curGroupMap.put(NAME, "Group " + i);
           
            List<Map<String, String>> children = new ArrayList<Map<String, String>>();
            for (int j = 0; j < 15; j++) {
                Map<String, String> curChildMap = new HashMap<String, String>();
                children.add(curChildMap);
                curChildMap.put(NAME, "Child " + j);
            }
            childData.add(children);
        }
       
        // Set up our adapter
        mAdapter = new SimpleExpandableListAdapter(
                this,
                groupData,
                android.R.layout.simple_expandable_list_item_1,
                new String[] { NAME },
                new int[] { android.R.id.text1, android.R.id.text2 },
                childData,
                android.R.layout.simple_list_item_multiple_choice,
                new String[] { NAME },
                new int[] { android.R.id.text1, android.R.id.text2 }
                );
        setListAdapter(mAdapter);
    }

}


I put the list_item_multiple_choice as child in ExpandableList.

And I want to set default checked checkbox in child list view.

How do i get the child list View to set the list item checked??
chisheng
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Dec 24, 2009 4:49 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests