/**
* Añade la cabecera a la tabla
* @param recursocabecera Recurso (array) donde se encuentra la cabecera de la tabla
*/
public void agregarCabecera(int recursocabecera)
{
TableRow.LayoutParams layoutCelda;
TableRow fila = new TableRow(actividad);
TableRow.LayoutParams layoutFila = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
fila.setLayoutParams(layoutFila);
String[] arraycabecera = rs.getStringArray(recursocabecera);
COLUMNAS = arraycabecera.length;
for(int i = 0; i < arraycabecera.length; i++)
{
TextView texto = new TextView(actividad);
layoutCelda = new TableRow.LayoutParams(obtenerAnchoPixelesTexto(arraycabecera[i]), TableRow.LayoutParams.WRAP_CONTENT);
texto.setText(arraycabecera[i]);
texto.setGravity(Gravity.CENTER_HORIZONTAL);
texto.setTextAppearance(actividad, R.style.estilo_celda);
texto.setBackgroundResource(R.drawable.tabla_celda_cabecera);
texto.setLayoutParams(layoutCelda);
fila.addView(texto);
}
tabla.addView(fila);
filas.add(fila);
FILAS++;
}
/**
* Agrega una fila a la tabla
* @param elementos Elementos de la fila
*/
public void agregarFilaTabla(ArrayList<String> elementos)
{
TableRow.LayoutParams layoutCelda;
TableRow.LayoutParams layoutFila = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
TableRow fila = new TableRow(actividad);
fila.setLayoutParams(layoutFila);
for(int i = 0; i< elementos.size(); i++)
{
TextView texto = new TextView(actividad);
texto.setText(String.valueOf(elementos.get(i)));
texto.setGravity(Gravity.CENTER_HORIZONTAL);
texto.setTextAppearance(actividad, R.style.estilo_celda);
texto.setBackgroundResource(R.drawable.tabla_celda);
layoutCelda = new TableRow.LayoutParams(obtenerAnchoPixelesTexto(texto.getText().toString()), TableRow.LayoutParams.WRAP_CONTENT);
texto.setLayoutParams(layoutCelda);
fila.addView(texto);
}
tabla.addView(fila);
filas.add(fila);
FILAS++;
}