2011-03-04 13 views
0

Je souhaite afficher un tableau de chaînes dans la disposition de table. Avoir le code suivant. Je suis capable d'obtenir les données dans le dossier de notation mais la disposition de table je ne vois rien.Problème lié à TableLayout

TableLayout tl=(TableLayout)findViewById(R.id.maintable); 
    for(int current=0;current<cursor1.getCount();current++) 
    { 
     //create a table row 
    TableRow tr=new TableRow(this); 
    tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
    // create a text view for start time 
    TextView sTime= new TextView(this); 
    sTime.setText(values[current]); 
    sTime.setTextColor(Color.YELLOW); 
    Log.i("Data Check", values[current]); 
    sTime.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
    tr.addView(sTime); 
    //add the table row into TableLayout 
    tl.addView(tr, new TableLayout.LayoutParams(
      LayoutParams.FILL_PARENT, 
      LayoutParams.WRAP_CONTENT)); 

    } 
+0

nous allons avoir besoin de votre mise en page xml ... –

+0

i juste après il. – PiyushMishra

+0

Vous avez le problème mais je ne peux pas le résoudre. chaque fois que je change la valeur de setText pour un texte statique cela fonctionne bien mais la chose est dans mon journal je peux voir les valeurs [courant] fonctionne correctement mais dans la disposition de table cela ne fonctionne pas. – PiyushMishra

Répondre

0

Je sais que c'est long après mais cela peut vous aider ou aider quelqu'un d'autre. Lorsque vous créez la ligne et ajoutez mise params à, utilisez le type suivant de params

TableRow.LayoutParams PAS Les TableLayout.LayoutParams