TableLayout in Android

November 15th, 2011 by aabhaanjan

droid_tool
TableLayout displays data in table view.
This example is for TableLayout :

Steps :
Step 1. Create a new android project.
Step 2. Give the project name.
Step 3. Open res/layout/main.xml

Step 4. Here is the code :
[xml]

android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:stretchColumns=”1″>
android:layout_column=”2″
android:text=”row1col1″
android:padding=”3dip” />
android:text=”row1col2″
android:gravity=”right”
android:padding=”3dip” />
android:layout_column=”2″
android:text=”row2col1″
android:padding=”3dip” />
android:text=”row2col2″
android:gravity=”right”
android:padding=”3dip” />
android:layout_column=”2″
android:text=”row3col1″
android:padding=”3dip” />
android:text=”row3col2″
android:gravity=”right”
android:padding=”3dip” />

android:layout_height=”2dip”
android:background=”#FF909090″ />

android:layout_height=”2dip”
android:background=”#FF909090″ />

[/xml]
Step 5.Run you app. it will look like this :
tableLayout

Tags: , , , , , ,