Acceder

Ver la Versión Completa : Null Pointer Exception al añadir una fila en una tabla


ayozito
27/04/12, 17:47:53
XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TableLayout android:id="@+id/TableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0">
</TableLayout>
</LinearLayout>



Código:

TableLayout table = (TableLayout) findViewById(R.id.TableLayout1);
TableRow row = new TableRow(this);
TextView t = new TextView(this);
t.setText("lalallala");
row.addView(t);
table.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT , LayoutParams.WRAP_CONTENT));


La última linea siempre peta, haga lo que haga. He probado miles de formas distintas y nada, siempre que llega ahí da el Null Pointer Exception.