【问题标题】:Adding custom list adapter to a TableLayout将自定义列表适配器添加到 TableLayout
【发布时间】:2011-07-26 20:27:32
【问题描述】:

我在 TableLayout 中有一个自定义列表适配器。这个 TableLayout 嵌套在一个 LinearLayout 中。

如果新的子视图被添加到列表中,列表适配器会扩展。当列表适配器的大小增加时,我希望 TableRow 的大小动态增加。当列表增长时,按钮被按下。

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent" android:layout_width="match_parent" 
    >

        <LinearLayout">
            <!-- Draw header + sub title -->
            <LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" >
                <TextView ></TextView>
                <TextView ></TextView>
            </LinearLayout>

            <LinearLayout android:orientation="horizontal">
                <ImageView />
                <LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" 
                    android:layout_weight="1">
                    <TableLayout android:layout_height="fill_parent" android:layout_width="fill_parent"  android:layout_weight="1">
                        <TableRow android:id="@+id/tr1">
                            <CustomList android:id="@+id/mainview"
                                ndroid:layout_height="wrap_content" android:layout_width="wrap_content" />
                        </TableRow>
                        <TableRow android:layout_height="wrap_content"
                            android:layout_width="match_parent">
                            <Button android:layout_width="wrap_content" android:id="@+id/button1"
                                android:text="@string/buttonPrevious" android:layout_height="wrap_content">
                            </Button>
                            <Button android:layout_width="wrap_content" android:id="@+id/button2"
                                android:text="@string/buttonNext" android:layout_height="wrap_content"></Button>
                        </TableRow>
                    </TableLayout>
                </LinearLayout>
                <ImageView  />

        </LinearLayout>
    </ScrollView>

我是否必须进行一些更改,例如更改自定义列表适配器中的布局膨胀方式或其他任何内容?

【问题讨论】:

标签: android android-listview listadapter


【解决方案1】:

请阅读以下问题和答案。我相信这可能是您想要实现的同一件事

Android ListView that does not scroll?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-16
    • 2017-10-15
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 2018-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多