簡體   English   中英

在表格行中插入表格行

[英]Inserting a table row inside a table row

我想在一個表行中垂直插入兩個表行。 這已經完成,但是行是水平添加的,而不是垂直添加的。 如何添加垂直行。以下是我的xml。

                <TableLayout 
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/TableLAyout1"
                >
                    <TableRow 
                        android:layout_width="fill_parent"

                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                    >
                        <TableRow
                        android:layout_column="0"
                        android:layout_width="fill_parent"
                        android:background="@drawable/eventbar"
                         android:layout_height="wrap_content"
                         android:id="@+id/TableRow1" >
                        <TextView 
                            android:gravity="center_vertical"
                            android:layout_width="wrap_content"
                            android:text="Calendar for 14 August 2011"
                            android:layout_height="wrap_content"
                            android:textColor="@drawable/white"
                            android:layout_marginLeft="10dp"
                        />
                        </TableRow>
                        <TableRow 
                        android:layout_column="0"
                            android:layout_below="@+id/TableRow1"
                           android:layout_width="fill_parent"
                           android:background="@drawable/bgrow"
                           android:layout_height="wrap_content">
                                <ListView 
                                    android:layout_height="wrap_content"
                                    android:layout_width="fill_parent"
                                    android:id="@+id/ListView2" >
                                </ListView>
                        </TableRow>
                    </TableRow>

                </TableLayout>

誰能幫我怎么做?

我認為您誤解了TableLayout工作原理。 如果您在本教程中進行了閱讀 ,將會看到TableLayout與HTML表的工作方式相似,這意味着TableRow實際上定義了row而不是column,並且甚至不打算這樣做。 列是根據您添加到行中的視圖自動創建的。

因此,如果要具有兩行且每個行都有兩個TextViews ,則只需將兩個TableRow添加到TableLayout ,然后將兩個TextView插入到每個行中。

我認為您應該做的是在主表行內有tableLayout,在內部表布局中可以有2行,並且在主表行上具有onclick事件。 即使我正在嘗試類似的方法,如果可以的話也會進行更新。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM