Swa*_*yam 3 android background-color expandablelistview
我想更改在ExpandableListView中单击的子项的背景颜色.也就是说,当点击任何孩子时,它的背景颜色应该被改变.我试图以这种方式去它,但它选择了一些其他行,而不是已被点击的那一行.
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
parent.getChildAt(childPosition).setBackgroundColor(Color.DKGRAY);
return false;
}
Run Code Online (Sandbox Code Playgroud)
请告诉我可能缺少的东西.
这就是我解决它的方式.
View _lastColored;
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
_groupPosition = groupPosition;
if(_lastColored != null)
{
_lastColored.setBackgroundColor(Color.TRANSPARENT);
_lastColored.invalidate();
}
_lastColored = v;
v.setBackgroundColor(Color.rgb(214, 214, 214));
return false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10239 次 |
| 最近记录: |