Android 使用阵列适配器实现可扩展列表

Android 使用阵列适配器实现可扩展列表,android,Android,我正在尝试实现一个从站点下载的预制库,以便在我的listview中使用它。它叫做可扩展列表视图,我想我们都知道它是什么 在XML文件列表视图中,如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:lay

我正在尝试实现一个从站点下载的预制库,以便在我的listview中使用它。它叫做可扩展列表视图,我想我们都知道它是什么

在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="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/text"
            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>

众所周知,数组列表需要listview只是textview才能工作,否则会引发异常


有人能告诉我这些东西在数组列表中是如何工作的吗?

您可以使用自定义适配器来实现这一点。有关如何操作的教程,请参见本教程。:)

我想你说的是定制适配器。以防万一,你检查这个来了解它:非常感谢,希望你把它作为答案,所以我接受