Addev
Addev

Reputation: 32233

Get group clicked in OnGroupClickListener

How can I retrieve the group clicked in a OnGroupClickListener of a ExpandableListView.

I have tried parent.getItemAtPosition(groupPosition) and it return groups and childs so I think I must convert the groupPosition to a absolute position in the adapter, but I don't know how to do it.

new OnGroupClickListener() {

        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                Item item= parent.getItemAtPosition(groupPosition);
            return true;
        }
    }

Upvotes: 0

Views: 271

Answers (1)

Yash Sampat
Yash Sampat

Reputation: 30611

Try this:

new OnGroupClickListener() {

    @Override
    public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {

        Object object = parent.getExpandableListAdapter().getGroup(groupPosition);

        ....
        ....

        return true;
    }
}

This should work.

Upvotes: 1

Related Questions