2011-10-11 144 views
0

我想在表格行中垂直插入两个表格行。 这是正在完成,但行被水平添加而不是垂直添加。如何添加垂直行 以下是我的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> 

任何人都可以帮助我如何做到这一点?

回答

3

我想你误会了TableLayout的工作原理。如果您阅读tutorial,您会看到,TableLayout与HTML表格的工作方式类似,这意味着TableRow实际上定义了,而不是列,甚至不打算执行其他操作。这些列是根据您添加到行的视图自动创建的。

因此,如果你想与每两个TextViews两行,你只是添加两个TableRow s到您的TableLayout,并插入两个TextView s转换他们每个人。

0

我认为你应该做的是在主表格行和内部的tablelayout里面放置tableLayout,你可以有2行,并且在主表格上有onclick事件。即使我正在尝试这样的事情,如果它有效,它也会更新。