0% found this document useful (0 votes)
5 views3 pages

Android TableLayout Examples and Exercises

The document discusses developing mobile applications using Android's TableLayout template. It provides two examples of TableLayout code for layouts. The first example demonstrates a three-row, multi-column layout. The second example shows a login form layout with labels, text fields and a submit button organized into rows. The document then outlines a two-part development exercise. Part one involves testing the two TableLayout examples. Part two tasks developers with creating (1) a calculator app for factorials using a numeric keypad layout and (2) a magic square generator that validates row, column and diagonal sums based on user-entered size. Validation of user input and instructions are also mentioned.

Uploaded by

J Uriel Cordero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Android TableLayout Examples and Exercises

The document discusses developing mobile applications using Android's TableLayout template. It provides two examples of TableLayout code for layouts. The first example demonstrates a three-row, multi-column layout. The second example shows a login form layout with labels, text fields and a submit button organized into rows. The document then outlines a two-part development exercise. Part one involves testing the two TableLayout examples. Part two tasks developers with creating (1) a calculator app for factorials using a numeric keypad layout and (2) a magic square generator that validates row, column and diagonal sums based on user-entered size. Validation of user input and instructions are also mentioned.

Uploaded by

J Uriel Cordero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Application Development for Mobile Devices.

Tema: Plantilla TableLayout.

Desarrollo:
Parte I.
Abrir un IDE para desarrollo en Android.
Crear un proyecto nuevo.
En la clase Java, invocar al [Link] abrirlo en el editor.
Insertar el cdigo de los dos siguientes ejemplos con el uso de la plantilla TableLayout.
Probar en forma independiente cada ejemplo.
Ejemplo 1:
<TableLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*" android:stretchColumns="*" android:background="#ffffff">
<!-- Fila 1 con 1 columna -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:textSize="18dp" android:text="Fila 1" android:layout_span="3"
android:padding="18dip" android:background="#b0b0b0"
android:textColor="#000"/>
</TableRow>
<!-- Fila 2 con 3 columnas -->
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/TextView04" android:text="Fila 2 columna 1"
android:layout_weight="1" android:background="#dcdcdc"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
<TextView
android:id="@+id/TextView04" android:text="Fila 2 columna 2"
android:layout_weight="1" android:background="#d3d3d3"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
<TextView
android:id="@+id/TextView04" android:text="Fila 2 columna 3"
android:layout_weight="1" android:background="#cac9c9"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
</TableRow>
<!-- Fila 3 con 2 columnas -->
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:id="@+id/TextView04" android:text="Fila 3 columna 1"
android:layout_weight="1 android:background="#b0b0b0"
android:textColor="#000000"
android:padding="18dip" android:gravity="center"/>
<TextView
android:id="@+id/TextView04" android:text="Fila 3 columna 2"

Android Bsico

Pgina 1

android:layout_weight="1" android:background="#a09f9f"
android:textColor="#000000"
android:padding="18dip" android:gravity="center"/>
</TableRow>
</TableLayout>

Ejemplo 2:
<TableLayout xmlns:android="[Link]
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow android:paddingTop="10px" android:gravity="center">
<TextView android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_span="2"
android:text="LOGIN"
android:textColor="#890000"
android:textSize="15sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:layout_marginTop="20dip" >
<TextView android:layout_width="wrap_content"
android:text="Username :"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginLeft="20dip"
></TextView>
<EditText
android:id="@+id/screenName"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_weight="1" >
</EditText>
</TableRow>
<TableRow android:layout_marginTop="20dip" >
<TextView android:text="Password :"
android:layout_width="wrap_content"
android:textSize="20sp"
android:textColor="#000000"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"></TextView>
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_weight="1" >
</EditText>
</TableRow>
<TableRow android:gravity="center" android:layout_marginTop="20dip" >
<Button android:text="Submit"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/save" android:layout_span="2" ></Button>
</TableRow>
</TableLayout>

Parte II.
Desarrollar los dos siguientes ejercicios. En cada ejercicio, incluir las variables de cadena en el archivo [Link].
Validar los datos de entrada del usuario. Agregar las etiquetas necesarias para instruir al usuario con el uso de la
aplicacin.
1. Disear una calculadora con la nica operacin del factorial:
a. Incluir un EditText para el ingreso de nmeros.
b. Incluir un TableLayout para el teclado numrico.
Android Bsico

Pgina 2

c. Asignar botones para los dgitos 0-9.


d. Asignar un botn para la operacin del factorial (!).
e. Asignar un botn para limpiar todo y preparar un nuevo clculo.
2. Disear un cuadro mgico de tamao impar.
a. Incluir un EditText para el ingreso del tamao del cuadro.
b. El resultado debe mostrar un TableLayout con el cuadro mgico con la comprobacin de la suma de
filas, columnas y diagonales principales.

Android Bsico

Pgina 3

You might also like