可扩展列表视图中的列

时间:2015-02-17 07:18:43

标签: android expandablelistview multiple-columns

我已经使用本教程来执行可扩展列表视图。 http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/。 但我想做一个小改动,如下图所示。我不知道用红色加下划线的项目。是否可以在可扩展列表视图中包含列?

.xml文件

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#f4f4f4"
    android:orientation="vertical" >

    <ExpandableListView
        android:id="@+id/lvExp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:cacheColorHint="#00000000" />
</LinearLayout>

任何人都可以帮助我。任何帮助将不胜感激。

enter image description here

1 个答案:

答案 0 :(得分:1)

您需要两个布局:可扩展标头和子项。在您的示例中,它们是list_itemgroup_item

编辑它们并添加其余字段。

如果对字段宽度使用权重,则可以将标题和行设置为网格。

简言之: 对于标题(group_layout),请使用包含四个TextView的LinearLayout(以权重2,1,1,1开头,并根据测试进行调整)。

对于行(list_item),请使用包含以下内容的RelativeLayout:

  • LinearLayout与组布局中的一个完全相同(四个TextView,其重量与您设置的相同)与Top对齐。
  • 两个与左对齐的TextView(浇头)。相应地设置属性below
  • 另外两个ImageView。也可以相应地对齐它们(右边和另一个旁边)

查看RelativeLayout参数以设置您的视图。