开发者

Inserting a table row inside a table row

I want to insert two table rows inside a table row vertically. this is being done but the rows are being added horizontally instead of vertically. How to add vertical rows.. Following is my 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>

Can anyone help me how to this?


I think you misunderstood how TableLayout works. If you read up in the tutorial you will see, that TableLayout works similarly to HTML tables, meaning that TableRow actually defines a row, not a column and is not even intended to do otherwise. The columns are created automatically based on the views you add to the rows.

Thus, if you want to have two rows with two TextViews each, you just add two TableRows to your TableLayout, and insert two TextViews into each of them.


I think what you should do is have tableLayout inside the main table row and in the inner tablelayout you can have 2 rows and have the onclick event on the main tablerow. Even I am trying something like this, will update if it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜