Good morning guys, I am new to Android, I have consulted many sites and would like to know how to add rows or records to a table on Android, I appreciate the collaboration.
Layout Code:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TableRow
android:id="@+id/Cabecera"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/ColumnaCedula"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Cédula"
android:textColor="#005500"
android:textSize="21dp" />
<TextView
android:id="@+id/ColumnaNombre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="5px"
android:text="Nombre Operario"
android:textColor="#005500"
android:textSize="21dp" />
<TextView
android:id="@+id/ColumnaCargo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Cargo"
android:textColor="#005500"
android:textSize="21dp" />
</TableRow>
<TableRow
android:id="@+id/SeparadorCabecera"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:id="@+id/LineaCabecera"
android:layout_width="fill_parent"
android:layout_height="2px"
android:layout_span="6"
android:background="#FFFFFF" >
</FrameLayout>
</TableRow>
</TableLayout>
Java Code: Add a row to the table when the button is clicked
public void AgregarFilaTabla(View view)
{
TableLayout tabla = (TableLayout) findViewById(R.id.tblOperarios);
String params[] = {"Dato 1", "Dato 2", "Dato 2"};
TableRow row = new TableRow(params);
tabla.addView(row);
}