我正在制作一个包含ExpandableListViewCheckedTextViewListView的自定义视图:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/filtersDialogView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="200dp"
    android:orientation="vertical" >

    <ExpandableListView
        android:id="@+id/filtersListView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <CheckedTextView
        android:id="@+id/onlyShowAvailableItemsCheckedTextView"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:checkMark="?android:attr/listChoiceIndicatorMultiple"
        android:gravity="center_vertical"
        android:paddingLeft="8dip"
        android:paddingRight="8dip"
        android:text="@string/OnlyShowAvailableItems" />

    <ListView
        android:id="@+id/categoriesListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>


问题是CheckTextView是固定的,并且两个列表正在独立滚动(对于该布局是正常的)。此外,当我从ExpandableListView展开列表项时,CheckedTextView和其他ListView被隐藏了。我想用所有这些元素制作一个列表,这些元素在我扩展第一个列表的元素时可以正确滚动和调整大小(第二个列表的单元格不可扩展)。我怎样才能做到这一点?是否有可能无需修改列表的适配器和CheckedTextView的控制器?
谢谢

最佳答案

我怎样才能做到这一点?是否有可能无需修改就可以做到
  列表的适配器和CheckedTextView的控制器?


我对此表示怀疑,尤其是当您有两个滚动视图ExpandableListViewListView时。我认为您唯一的选择是一个特殊的适配器,它将模拟上面的布局。我有一个自定义的ExpandableListView适配器,我将其修改为可以模拟上述布局的东西。这是原始的,因此可能会有一些错误(我已经对其进行了一些测试),当然还有其他事情需要处理。代码示例有点大,所以我把它放在这里https://gist.github.com/3046887

关于android - 如何将多个ui元素合并到android中的listview中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11324545/

10-11 22:29
查看更多