0
Je travaille sur une application qui doit ajouter dynamiquement des lignes à une table avec 2 colonnes. Ci-dessous le code que je utilise .... Je reçois une erreur "FORCECLOSE" ... PLSS aider ....Ajout dynamique de lignes à un TableLayout dans Android
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/b1" />
</TableRow>
</TableLayout>
c'est mon code java
TableLayout tb=(TableLayout)findViewById(R.id.table);
TableRow tr=new TableRow(getBaseContext());
Button b1=(Button)findViewById(R.id.b1);
LayoutParams lp=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
tr.setLayoutParams(lp);
b1.setLayoutParams(lp);
b1.setText("I NEED HELP ! SOS ");
tr.addView(b1);
tb.addView(tr,lp);