Does anyone know how I can make items in an ExpandableListView clickable?
I've implemented this template: How do an Expandable ListView? and now I would like to be able to click on the items and open a new activity or fragment.
Does anyone know how I can make items in an ExpandableListView clickable?
I've implemented this template: How do an Expandable ListView? and now I would like to be able to click on the items and open a new activity or fragment.
You should indicate to the ExpandableListView an OnChildClickListener to use / call whenever an item is clicked:
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
//abra aqui a nova Activiy
return true;
}
});
The groupPosition
parameter receives the index of the group whose item ( childPosition
) was clicked.
Based on these two values open the new activity.