Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ExpandableListView错误_Android_Xml_Android Layout_Expandablelistview - Fatal编程技术网

Android ExpandableListView错误

Android ExpandableListView错误,android,xml,android-layout,expandablelistview,Android,Xml,Android Layout,Expandablelistview,我有一个ExpandableListView,当我单击一个子项时,背景颜色设置为绿色。这很好,但当我展开另一个组时,上一个背景色设置为打开组的第一个元素,并从上一个项目中消失。这似乎是一个错误,但我不知道如何解决它,有人做过同样的实验吗? 下面是我的简单代码: 这是row元素的最大值: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/

我有一个ExpandableListView,当我单击一个子项时,背景颜色设置为绿色。这很好,但当我展开另一个组时,上一个背景色设置为打开组的第一个元素,并从上一个项目中消失。这似乎是一个错误,但我不知道如何解决它,有人做过同样的实验吗? 下面是我的简单代码:

这是row元素的最大值:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/equipRow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/checkBox1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/checkBox1"
        android:gravity="center_vertical|center_horizontal"
        android:text="Example"
        android:textColor="@android:color/background_dark"
        android:textColorHint="@android:color/background_dark"
        android:textSize="25dp" />
</RelativeLayout>

这不是虫子。。。这是一个功能。。。尝试阅读Android上的ListView(特别是关于通过适配器重用视图的内容…)您应该将选定的项目存储在某个位置,并根据存储的选择在getView中为项目添加颜色…好的,这是我使用的方式,但我不知道此功能的目的,
private void ItemClick(){
        this.getExpandableListView().setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

            public boolean onChildClick(ExpandableListView parent, View v,
                    int groupPosition, int childPosition, long id) {
                RelativeLayout rL = (RelativeLayout)v;
                TextView eView = (TextView) (((RelativeLayout)v).findViewById(R.id.equipRow));

                eView.setBackgroundColor(Color.argb(150,66, 165, 29));
                exListAdapter.notifyDataSetChanged();

                return true;
            }
        });
    }