0

https://github.com/tjerkw/Android-SlideExpandableListView

所以使用上面的库并在中添加了另一个文本视图:

<?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="wrap_content"
              android:orientation="vertical">
    <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

        <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/textA"
                android:text="Hello World"/>

        <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/textB"
                android:text="Hello World"/>

        <!-- this is the button that will trigger sliding of the expandable view -->
        <Button
                android:id="@+id/expandable_toggle_button"
                android:text="More"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/text"
                android:layout_alignParentRight="true"
                android:layout_alignTop="@id/text"/>

    </RelativeLayout>

    <!-- this is the expandable view that is initially hidden and will slide out when the more button is pressed -->
    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal"
            android:id="@+id/expandable"
            android:background="#000000">

        <!-- put whatever you want in the expandable view -->
        <Button
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="0.5"
                android:text="Action A" />

        <Button
                android:id="@+id/details"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="0.5"
                android:text="Action B"/>

    </LinearLayout>
</LinearLayout>

在设置列表适配器中,您只能指定一个 R.id.TextA。您如何为两个 textView 指定两个项目列表。

4

1 回答 1

1

回答可能为时已晚,但使用 SimpleCursorAdapter 您可以像这样传递一组 TextViews:

SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, 
            R.layout.expandable_list_item, c, 
            new String[] {DB_COL_A, DB_COL_B}, 
            new int[] {R.id.textA, R.id.textB});
于 2013-10-04T12:25:57.157 回答