子视图被推送到父ExpandableListView组件中

时间:2014-09-23 08:05:24

标签: android expandablelistview expandablelistadapter

我一直在为客户端需求开发多级ExpandableListView组件。所以我现在有4个级别,当我点击第4个级别的最后一个项目时,父项目被推入ExpandableListView,这不是我想要的和正确的方法。请帮助我如何在单击子视图时避免这种情况,父视图会相应地展开和滚动,以便父项不会在其他视图中丢失。下面是我现在所拥有的截图,下面给出了这些的布局文件。

enter image description here

client_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:background="@color/background"
    android:orientation="vertical"
    android:paddingBottom="8dp"
    android:paddingLeft="5dp"
    android:paddingRight="8dp"
    android:paddingTop="5dp" >

    <TextView
        android:id="@+id/lblListHeader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
        android:paddingRight="0dp"
        android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
        android:textColor="@color/black"
        android:textSize="17dp" />

    <ExpandableListView
        android:id="@+id/expandableList2"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:indicatorLeft="250dp" />

</LinearLayout>

property_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:background="@color/background"
    android:orientation="vertical"
    android:paddingBottom="8dp"
    android:paddingLeft="15dp"
    android:paddingRight="8dp"
    android:paddingTop="5dp" >

    <TextView
        android:id="@+id/lblPropertyHeader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
        android:paddingRight="0dp"
        android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
        android:textColor="@color/black"
        android:textSize="17dp" />

    <ExpandableListView
        android:id="@+id/propertyList"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:choiceMode="singleChoice" />

</LinearLayout>

unit_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:background="@color/background"
    android:orientation="vertical"
    android:paddingBottom="8dp"
    android:paddingLeft="25dp"
    android:paddingRight="8dp"
    android:paddingTop="5dp" >

    <TextView
        android:id="@+id/lblPropertyHeader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
        android:paddingRight="0dp"
        android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
        android:textColor="@color/black"
        android:textSize="17dp" />

    <ExpandableListView
        android:id="@+id/propertyList"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" 
        android:choiceMode="singleChoice"/>

</LinearLayout>

ticket_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@color/background"
    android:orientation="vertical"
    android:paddingBottom="0dp"
    android:paddingLeft="33dp"
    android:paddingRight="8dp"
    android:paddingTop="0dp" >

    <TextView
        android:id="@+id/lblListItem"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="5dp"
        android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
        android:paddingRight="0dp"
        android:paddingStart="?android:attr/expandableListPreferredChildPaddingLeft"
        android:paddingTop="5dp"
        android:textSize="17dip" />

</RelativeLayout>

0 个答案:

没有答案