How To Get Child Position From Expandablelistview
How to get child position from expandable List View android. I want to get child position from expandable list view setSelect automatically.
Solution 1:
expListView.setOnChildClickListener(new OnChildClickListener() {
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
final String selected = (String) expListAdapter.getChild(
groupPosition, childPosition);
Toast.makeText(getBaseContext(), selected, Toast.LENGTH_LONG)
.show();
return true;
}
});
Solution 2:
You have to use Adapter's getChild(groupPosition, childPosition)
method to retrieve the instance of child.
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(this, (String)((Map<String, String>)
adapter.getChild(groupPosition, childPosition)).get(childPosition),
Toast.LENGTH_LONG).show();
return super.onChildClick(parent, v, groupPosition, childPosition, id);
}
Post a Comment for "How To Get Child Position From Expandablelistview"