简体   繁体   中英

ExpandableListView - setOnChildClickListener and get Parent/Group view

How can i have access to group view by setOnChildClickListener() ?

I want to change the group item background when the child has been clicked.

Well, in OnChildClickListener#onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) you have groupPosition.

You should have a back-up model with model data for both groups and children. On call to above method you would say something like: getModelData().getGroupItem(groupPosition).setValue(some_custom_value).

And then call parent#notifyDataSetInvalidated(); That will trigger a full layout and redraw for list.

Within getGroupView() you should have some logic to determine how to draw the background based on above getModelData().getValue().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM