Very often we will want to lay out our information in columns and rows and when we do, Android provides us with the TableLayout and TableRow classes. TableLayout and TableRow are very similar to the HTML <table>
and
<tr>
tags, although any Android view can be used as a cell, including another TableLayout. The system also includes several handy techniques for managing and organizing our tables.
Start up an Android project in Eclipse and navigate to the main.xml
file in the res/layout
folder.
Change the root node of the layout file from
LinearLayout
toTableLayout
, and delete the default TextView and theandroid:orientation="vertical"
attribute, leaving the code looking like this:<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </TableLayout>
Switch to the Graphical Layout...