0

是否可以在 ExpandableListView 的项目中放置多个 TextView?我试过这个,但不工作,第二台电视没有显示:

group_item.xml

<TextView android:id="@+id/row_name"
     android:paddingLeft="5dp"
     android:textSize="18dp"
     android:textColor="@color/black"
     android:textStyle="normal"
     android:layout_width="320dp"
     android:layout_height="wrap_content"/>

<TextView android:id="@+id/row_desc"
    android:text="Some text here"
     android:paddingLeft="5dp"
     android:textSize="18dp"
     android:textColor="@color/black"
     android:textStyle="normal"
     android:layout_width="320dp"
     android:layout_height="wrap_content"/>

4

3 回答 3

1

你还没有说是什么支持你的列表视图,所以我将展示一个带有游标的示例(假设是 SimpleCursorTreeAdapter)。

mAdapter = new MyExpandableListAdapter(
    mGroupsCursor,                                  // cursor supplying group data
    getActivity(),                                  // context
    R.layout.group_item,                            // Group row layout
    R.layout.child_item,                            // Child row layout
    new String[] { "column1", "column2" },          // Cursor columns from group cursorto be mapped to group view
    new int[] { R.id.row_name, R.id.row_desc },     // View ids to receive group column data
    new String[] { "child1", "child2"},             // Cursor columns from child cursor to be mapped to child view
    new int[] { R.id.child1, R.id.child2            // View ids to receive child column data
});    
lv.setAdapter(mAdapter);                        // Set your adapter
于 2012-05-20T22:46:05.770 回答
0

对的,这是可能的。但是你必须自己做绑定。因此制作一个自定义适配器并覆盖 bindGroupView 或 bindChildView 方法。

-编辑-

对不起,我对这个问题有点困惑。如果您只想填充两个文本视图,那么您不必覆盖 bindgroupview 或 bindchildview 方法。仅当您需要进行更复杂的绑定时。

于 2012-05-20T20:59:34.093 回答
0

是的,有可能是我添加到 github 的示例。

我正在这个项目中处理冻结列 exp。别理他们。在适配器中,您将看到多个列

https://github.com/huseyinDaVinci/Android/tree/master/ExpandableListView

于 2014-12-29T08:32:23.667 回答