Expandablelistview Clickable Items

Asked

Viewed 70 times

1

Does anyone know how I make the items in an Expandablelistview clickable?

I implemented this model: How to make an expandable Listview? and now I would like to be able to click on the items and open a new Activity or Fragment.

1 answer

1


You must provide Expandablelistview with a Onchildclicklistener for it 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 parameter groupPosition receives the group index whose item(childPosition) was clicked.
Depending on these two values open the new Activity.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.