Sunday, March 3, 2013

How to Format a Table on TextView for Android



1. Double-click the 'Eclipse.exe' shortcut on your desktop and load the Android app project in the editing software.

2. Add the 'TextView' definition to the XML. The following code creates a TextView definition to the Android screen:

android:layout_column='1'

android:text='My Table Layout'

android:padding='3dip' />

3. Double-click the main XML file you use to display the table. Add the table layout XML tag. The following code defines the table and stretches the table across the TextView, so it fills the screen with the table information:android:layout_width='fill_parent'

android:layout_height='fill_parent'

android:stretchColumns='1'>

4. Add columns to the table layout. You use another 'TextView' object to display content in the table's columns. The following code adds a column to your table and displays 'Hello World' in the column:

android:layout_column='1'

android:text='Hello World'

android:padding='3dip' />

5. Save the changes and click the 'Run' button in the main toolbar to open the new layout in the Android emulator, so you can review the changes.

No comments:

Post a Comment