Android ExpandableListView-setOnChildClickListener和get Parent/Group视图

Android ExpandableListView-setOnChildClickListener和get Parent/Group视图,android,expandablelistview,Android,Expandablelistview,如何通过setOnChildClickListener()访问组视图 我想在单击子项时更改组项背景。好的,在OnChildClickListener\onChildClick(ExpandableListView父项,视图v,int-groupPosition,int-childPosition,long-id)中,您有groupPosition 您应该有一个备份模型,其中包含组和子组的模型数据。在调用上述方法时,您可能会说:getModelData().getGroupItem(groupPo

如何通过setOnChildClickListener()访问组视图


我想在单击子项时更改组项背景。

好的,在
OnChildClickListener\onChildClick(ExpandableListView父项,视图v,int-groupPosition,int-childPosition,long-id)
中,您有groupPosition

您应该有一个备份模型,其中包含组和子组的模型数据。在调用上述方法时,您可能会说:getModelData().getGroupItem(groupPosition).setValue(一些自定义值)

然后调用
parent#notifyDataSetionValidated()将触发完整布局并重新绘制列表

getGroupView()
中,您应该有一些逻辑来确定如何基于上述getModelData().getValue()绘制背景