繁体   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