How To Handle Android Simpleexpandablelistadapter Entry Selection
I have created an expandable list in my Android application using the SimpleExpandableListAdapter type. But I'm at a complete loss as to how I detect events when one of the child e
Solution 1:
It should be:
list.setOnChildClickListener(newExpandableListView.OnChildClickListener() {
publicvoidonChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Objecto= (Object)adapter.getChild(groupPosition, childPosition);
// perform work on child object here
}
}
Though, it sounds like you tried this... ExpandableListView.OnChildClickListener says that it is, in fact, the way to do it.
Also, have you defined the methods allItemsAreEnabled() and/or isEnabled() for your ListAdapter? You shouldn't have to, but maybe they are currently defined and returning the wrong values?
Solution 2:
Also...
If you happen to be using a class that extends BaseExpandableListAdapter then their is a default implemented method you'll have to set the return boolean for.
@OverridepublicbooleanisChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stubreturntrue;
}
By default this method is returning false, swap to true(if this is the case) and your OnChildClickListener should start resolving correctly.
Post a Comment for "How To Handle Android Simpleexpandablelistadapter Entry Selection"