我已经使用onChildClickListener来处理子点击,但不知道如何更改父文本颜色:
val clickListener = ExpandableListView.OnChildClickListener{
listView: ExpandableListView?, v: View?
, groupPosition: Int, _: Int, _: Long
->
listView?.collapseGroup(groupPosition)
true
}
expandable_list_view.setOnChildClickListener(clickListener)
答案 0 :(得分:1)
I think the best way would be to Create a list of parents that need colors changed and update them in get parent view, just like nosugar said
Set<Integer> coloredParents = new HashSet<Integer>();
val clickListener = ExpandableListView.OnChildClickListener{
listView: ExpandableListView?, v: View?
, groupPosition: Int, _: Int, _: Long
->
listView?.collapseGroup(groupPosition)
if(coloredParents.contains(groupPosition))
{
coloredParents.remove(groupPosition);
}
else
{
coloredParents.put(groupPosition);
}
true
}
expandable_list_view.setOnChildClickListener(clickListener)
//then in groupview
View getGroupView(int groupPosition)
{
if(coloredParents.contains(groupPosition))
{
//set color here
}
}