You are using

final ListView listView = getExpandableListView();
        listView.setItemsCanFocus(false);
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

but you are extending ExpandableListActivity, not ListActivity. To use
chekboxes properly you have to use mAdapter variable..


On Jul 14, 5:35 am, kostmo <[email protected]> wrote:
> I would like to haveexpandabletext categories which reveal children
> that are checkable entries.
> I've used the "simple_list_item_multiple_choice" layout for the
> childLayout argument of SimpleExpandableListAdapter.
>
> The activity shows up correctly, but when a child item is clicked, the
> check box will not toggle.
>
> I haven taken code from List11.java and ExpandableList3.java from the
> ApiDemos project.
>
> ====================================================
> package com.kostmo.android.test;
>
> import java.util.ArrayList;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
>
> import android.app.ExpandableListActivity;
> import android.os.Bundle;
> import android.widget.ExpandableListAdapter;
> import android.widget.ListView;
> import android.widget.SimpleExpandableListAdapter;
>
> public class ExpandableFeatureSelector 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 (String database_name : AvailableCategories) {
>             Map<String, String> curGroupMap = new HashMap<String,
> String>();
>             groupData.add(curGroupMap);
>             curGroupMap.put(NAME, database_name);
>
>            List<Map<String, String>> children = new
> ArrayList<Map<String, String>>();
>             for (String download_option : AvailableFeatures) {
>                 Map<String, String> curChildMap = new HashMap<String,
> String>();
>                 children.add(curChildMap);
>                 curChildMap.put(NAME, download_option);
>             }
>             childData.add(children);
>         }
>
>         mAdapter = new SimpleExpandableListAdapter(
>                 this,
>                 groupData,
>                 android.R.layout.simple_expandable_list_item_1,
>                 new String[] { NAME },
>                 new int[] { android.R.id.text1 },
>                 childData,
>                 android.R.layout.simple_list_item_multiple_choice,
>                 new String[] { NAME },
>                 new int[] { android.R.id.text1 }
>                 );
>         setListAdapter(mAdapter);
>
>         final ListView listView = getExpandableListView();
>         listView.setItemsCanFocus(false);
>         listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
>     }
>
>     private static final String[] AvailableCategories = new String[] {
>         "Books", "Clothes", "Cars"
>     };
>
>     private static final String[] AvailableFeatures = new String[] {
>         "Damaged", "Used"
>     };
>
> }
>
> ====================================================

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to