Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/11/2011, 15:18
letni
 
Fecha de Ingreso: octubre-2008
Mensajes: 276
Antigüedad: 15 años, 6 meses
Puntos: 1
Pregunta Respuesta: Listado dinámico para integrar con SQLite

Hola,

He visto que es posible. He implementado este código pero no tiene efecto:

El layout:
Código:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myTableLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
     <TableRow
          android:layout_width="fill_parent"
          android:layout_height="wrap_content">
          
          <Button android:text="Static Button"/>
     </TableRow>
</TableLayout>
La activity:
Código:
public class MostrarListadoActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.mostrarlistadoactivity);
	    /* Find Tablelayout defined in main.xml */
	    TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);
	    /* Create a new row to be added. */
	    TableRow tr = new TableRow(this);
	    tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
	    /* Create a Button to be the row-content. */
	    Button b = new Button(this);
	    b.setText("Dynamic Button");
	    b.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
	    /* Add Button to row. */
	    tr.addView(b);
	    /* Add row to TableLayout. */
	    tl.addView(tr,new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    }
}
Sólo se ve el botón estático definido en el documento xml.

¿Qué puede estar pasando para que no se muestre el botón creado en tiempo de ejecución?
__________________
Uso Apache 2.2 con PHP 5.5.9 y MySQL 5.1
Uso Eclipse IDE for Java Developers, Version: Mars.1 Release (4.5.1), Build id: 20150924-1200 para programar en Java bajo Windows