[android-developers] Re: How to use CheckBox as children in ExpandableList?
I got it works, but how can I get which item was checked by users? Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How to use CheckBox as children in ExpandableList?
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 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> groupData = new > ArrayList>(); > List>> childData = new > ArrayList>>(); > > for (String database_name : AvailableCategories) { > Map curGroupMap = new HashMap String>(); > groupData.add(curGroupMap); > curGroupMap.put(NAME, database_name); > > List> children = new > ArrayList>(); > for (String download_option : AvailableFeatures) { > Map curChildMap = new HashMap 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How to use CheckBox as children in ExpandableList?
Hello kostmo, use the following code to toggle checkbox @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { CheckedTextView tempView = (CheckedTextView)v.findViewById (android.R.id.text1); tempView.setChecked(!tempView.isChecked()); return super.onChildClick(parent, v, groupPosition, childPosition, id); } On Jul 21, 11:16 am, "anki_dai...@yahoo.com" wrote: > 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 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> groupData = new > > ArrayList>(); > > List>> childData = new > > ArrayList>>(); > > > for (String database_name : AvailableCategories) { > > Map curGroupMap = new HashMap > String>(); > > groupData.add(curGroupMap); > > curGroupMap.put(NAME, database_name); > > > List> children = new > > ArrayList>(); > > for (String download_option : AvailableFeatures) { > > Map curChildMap = new HashMap > 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" > > }; > > > } > > > - Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How to use CheckBox as children in ExpandableList?
Hello Kostmo use the following code to toggle check box @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { CheckedTextView tempView = (CheckedTextView)v.findViewById (android.R.id.text1); tempView.setChecked(!tempView.isChecked()); return super.onChildClick(parent, v, groupPosition, childPosition, id); } On Jul 21, 11:16 am, "anki_dai...@yahoo.com" wrote: > 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 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 ofSimpleExpandableListAdapter. > > > 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> groupData = new > > ArrayList>(); > > List>> childData = new > > ArrayList>>(); > > > for (String database_name : AvailableCategories) { > > Map curGroupMap = new HashMap > String>(); > > groupData.add(curGroupMap); > > curGroupMap.put(NAME, database_name); > > > List> children = new > > ArrayList>(); > > for (String download_option : AvailableFeatures) { > > Map curChildMap = new HashMap > String>(); > > children.add(curChildMap); > > curChildMap.put(NAME, download_option); > > } > > childData.add(children); > > } > > > mAdapter = newSimpleExpandableListAdapter( > > 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" > > }; > > > } > > > - Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How to use CheckBox as children in ExpandableList?
Has anyone tried this yet. I am getting strange results. When I click on one of the check boxes a second one will sometimes become checked also. On Aug 3, 1:04 am, powerbyte wrote: > Hello Kostmo > use the following code to toggle check box > > �...@override > public boolean onChildClick(ExpandableListView parent, View v, int > groupPosition, int childPosition, long id) > { > CheckedTextView tempView = (CheckedTextView)v.findViewById > (android.R.id.text1); > tempView.setChecked(!tempView.isChecked()); > return super.onChildClick(parent, v, groupPosition, > childPosition, id); > } > > On Jul 21, 11:16 am, "anki_dai...@yahoo.com" > wrote: > > > 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 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 ofSimpleExpandableListAdapter. > > > > 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> groupData = new > > > ArrayList>(); > > > List>> childData = new > > > ArrayList>>(); > > > > for (String database_name : AvailableCategories) { > > > Map curGroupMap = new HashMap > > String>(); > > > groupData.add(curGroupMap); > > > curGroupMap.put(NAME, database_name); > > > > List> children = new > > > ArrayList>(); > > > for (String download_option : AvailableFeatures) { > > > Map curChildMap = new HashMap > > String>(); > > > children.add(curChildMap); > > > curChildMap.put(NAME, download_option); > > > } > > > childData.add(children); > > > } > > > > mAdapter = newSimpleExpandableListAdapter( > > > 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" > > > }; > > > > } > > > > - Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: How to use CheckBox as children in ExpandableList?
It is woking fine for me. paste onCreate code here to analyze your problem better. On Mon, Aug 17, 2009 at 5:06 AM, frankjoshua wrote: > > Has anyone tried this yet. I am getting strange results. When I click > on one of the check boxes a second one will sometimes become checked > also. > > On Aug 3, 1:04 am, powerbyte wrote: > > Hello Kostmo > > use the following code to toggle check box > > > > @Override > > public boolean onChildClick(ExpandableListView parent, View v, int > > groupPosition, int childPosition, long id) > > { > > CheckedTextView tempView = (CheckedTextView)v.findViewById > > (android.R.id.text1); > > tempView.setChecked(!tempView.isChecked()); > > return super.onChildClick(parent, v, groupPosition, > > childPosition, id); > > } > > > > On Jul 21, 11:16 am, "anki_dai...@yahoo.com" > > wrote: > > > > > 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 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 ofSimpleExpandableListAdapter. > > > > > > 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> groupData = new > > > > ArrayList>(); > > > >List>> childData = new > > > > ArrayList>>(); > > > > > > for (String database_name : AvailableCategories) { > > > > Map curGroupMap = new HashMap > > > String>(); > > > > groupData.add(curGroupMap); > > > > curGroupMap.put(NAME, database_name); > > > > > >List> children = new > > > > ArrayList>(); > > > > for (String download_option : AvailableFeatures) { > > > > Map curChildMap = new HashMap > > > String>(); > > > > children.add(curChildMap); > > > > curChildMap.put(NAME, download_option); > > > > } > > > > childData.add(children); > > > > } > > > > > > mAdapter = newSimpleExpandableListAdapter( > > > > 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" > > > > }; > > > > > > } > > > > > > - Hide quoted > text - > > > > > - Show quoted text - > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---