Saturday, March 30, 2013

TableLayout use in android xml.

The code has been written in two files
a) main.xml
b) tableActivity.java

The code is as follows

a) main.xml


<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TableRow>
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Table Row1 Button1" />
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Table Row1 Button2" />
    </TableRow>
    <TableRow>
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Table Row2 Button1" />
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Table Row2 Button2" />
    </TableRow>
    <TableRow>
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Table Row3 Button1" />
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Table Row3 Button2" />
    </TableRow>
</TableLayout>



b) tableActivity.java


package org.example.table;

import android.app.Activity;
import android.os.Bundle;

public class tableActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

No comments:

Post a Comment