1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// Récupération du TableLayout
TableLayout tl = (TableLayout) findViewById(R.id.maintable);
int current = 1321;//Identifiant de ta colonne (soit défini, soit aléatoire)
// Création d'un TableRow
TableRow tr = new TableRow(this);
tr.setId(100 + current);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
// 1er TextView
TextView labelTV = new TextView(this);
labelTV.setId(200+current);
labelTV.setText("toto");
labelTV.setTextColor(Color.BLACK);
labelTV.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tr.addView(labelTV);
// 2eme TextView
TextView valueTV = new TextView(this);
valueTV.setId(300+current);
valueTV.setText("toto2");
valueTV.setTextColor(Color.BLACK);
valueTV.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tr.addView(valueTV);
// Ajout de la ligne dans le tableau
tl.addView(tr, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT)); |
Partager