Pages

Wednesday, May 19, 2010

Android TableLayout


BlackBerry Bold 9700 Phone (AT&T)Motorola DROID A855 Android Phone (Verizon Wireless)HTC DROID INCREDIBLE Android Phone (Verizon Wireless)BlackBerry Storm2 9550 Phone (Verizon Wireless)

TableLayout: 

By seeing the word ‘Table’ itself we know that Table Layout is used to show views in a table format with rows & columns.
How to add rows in a table layout?
  • TableRow is used to add rows in a table layout.
  • TableRow is a layout. It will arrange its children horizontally. If the table row parent is not table layout, then it will work like a horizontal linear layout.
  • Each TableRow will define a single row in table. (If we create 10 TableRows it will define 10 rows in a table).
How to add columns in a table layout?
  • We can use any view to add a column in TableRow.
  • We can add multiple columns by adding multiple views in a TableRow.
For instance,
******************************************************************
xml version="1.0? encoding="utf-8??>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
03android:layout_width="fill_parent"
04android:layout_height="fill_parent"
05android:stretchColumns="1?>
06<TableRow>
07<TextView android:text="New"
08android:padding="3dip" />
09<TextView android:text="Ctrl+N"
10android:gravity="right"
11android:padding="3dip" />
12TableRow>
13<TableRow>
14<TextView android:text="Import"
15android:padding="3dip" />
16TableRow>
17<TableRow>
18<TextView android:text="Exit"
19android:padding="3dip" />
20<TextView android:text="Ctrl+E"
21android:gravity="right"
22android:padding="3dip" />
23TableRow>
24TableLayout>

******************************************************************

No comments:

Post a Comment