更改 ExpendbleListView 的组颜色在 android 中效果不佳

change group Color of ExpendbleListView is not work good in android

你好,当用户点击它并且群组折叠时,我使用此代码更改群组背景

expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

            @Override
            public boolean onGroupClick(ExpandableListView parent, View v,
                                        int groupPosition, long id) {
                if (!parent.isGroupExpanded(groupPosition)) {
                    v.setBackgroundColor(Color.parseColor("#ff9600"));
                } else  {
                    v.setBackgroundColor(Color.parseColor("#4fc1e9"));

                }
                if (parent.isGroupExpanded(groupPosition)) {
                    Toast.makeText(AdieActivity.this,String.valueOf( groupPosition), Toast.LENGTH_SHORT).show();
                }


                return false;
            }
        });

当用户点击和组opne时,背景颜色改变了但问题是,一些组没有打开但背景也改变了

覆盖的方法包含在我的自定义 ExpandableListAdapter 中。

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
    View view, ViewGroup parent)
{
     LinearLayout bevGroup = (LinearLayout) view.findViewById(R.id.myid);

if(isExpanded)
{
    bevGroup.setBackgroundColor(context.getResources().getColor(R.color.bgGroupBlack));
}
else
{
    bevGroup.setBackgroundColor(context.getResources().getColor(R.color.bgTransparent));
}
}