Note that there are some explanatory texts on larger screens.

plurals
  1. POCheckbox OnCheckedChange in expandablelist childs
    primarykey
    data
    text
    <p>How do i set a OnCheckedChangeListener on each childelements checkbox? I can't figure it out. When i check a checkbox i want a Toast popping up , telling me which child i have checked :)</p> <p>Source:</p> <pre><code>public class ExpandableActivity extends ExpandableListActivity { private String[] alphabet = { "a", "b", "c", "d", "e", "f", "g" }; private String c; ArrayList&lt;ArrayList&lt;Integer&gt;&gt; check_states = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;(); private Context context; @SuppressWarnings("unchecked") @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Create an array of Strings, that will be put to our ListActivity setContentView(R.layout.expandablelist); Bundle extras = getIntent().getExtras(); c = extras.getString("category"); SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter( this, createGroupList(), // Creating group List. R.layout.group_row, // Group item layout XML. new String[] { "Group Item" }, // the key of group item. new int[] { R.id.row_name }, // ID of each group item.-Data // under the key goes into // this TextView. createChildList(), // childData describes second-level // entries. R.layout.child_row, // Layout for sub-level entries(second // level). new String[] { "Sub Item" }, // Keys in childData maps to // display. new int[] { R.id.grp_child } // Data under the keys above go // into these TextViews. ); setListAdapter(expListAdapter); // setting the adapter in the list. } @SuppressWarnings({ "rawtypes", "unchecked" }) private List createGroupList() { ArrayList result = new ArrayList(); for (String s : alphabet) { // 15 groups........ HashMap m = new HashMap(); if (getResources().getIdentifier(c + s + "_name", "string", "dk.android.houseenabler") != 0) { int id = getResources().getIdentifier(c + s + "_name", "string", "dk.android.houseenabler"); getResources().getText(id); m.put("Group Item", getResources().getText(id)); // the key and // it's // value. } else { return result; } result.add(m); } return result; } @SuppressWarnings({ "rawtypes", "unchecked" }) private List createChildList() { ArrayList&lt;ArrayList&gt; result = new ArrayList&lt;ArrayList&gt;(); for (String s : alphabet) { if (getResources().getIdentifier(c + s + "_name", "string", "dk.android.houseenabler") != 0) { int id = getResources().getIdentifier(c + s, "array", "dk.android.houseenabler"); String[] Rchilds = getResources().getStringArray(id); ArrayList&lt;HashMap&gt; secList = new ArrayList&lt;HashMap&gt;(); for (String d : Rchilds) { HashMap childs = new HashMap(); childs.put("Sub Item", d); secList.add(childs); } result.add(secList); } else { return result; } } return result; } @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // GET TITLE int idTitle = getResources().getIdentifier(c + alphabet[groupPosition], "array", "dk.android.houseenabler"); String[] Rchilds = getResources().getStringArray(idTitle); // GET Desctiption int idDesc = getResources().getIdentifier( c + alphabet[groupPosition] + "_desc", "array", "dk.android.houseenabler"); String[] RDesc = getResources().getStringArray(idDesc); Intent intent2 = new Intent().setClass(this, Description.class); intent2.putExtra("title", Rchilds[childPosition]); intent2.putExtra("description", RDesc[childPosition]); startActivity(intent2); return true; } /* This function is called on expansion of the group */ public void onGroupExpand(int groupPosition, View v, ViewGroup vg) { } } </code></pre> <p>Here is an image of the running application. <img src="https://i.stack.imgur.com/03O7O.jpg" alt="http://www.thomasbolander.dk/app.jpg"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload