2016-09-22 4 views

Répondre

0

Essayez ce code:

int count=20 
    TableLayout tl=(TableLayout)findViewById(R.id.mainLayout); //table layout in xml 
           for(int i=0;i<count;i++) 
           { 

            TableRow tr = new TableRow(this); 
            tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
            TextView textview = new TextView(this); 
            textview.setText("hello"); 
            tr.addView(textview); 


            tl.addView(tr, new TableLayout.LayoutParams(
              LayoutParams.FILL_PARENT, 
             LayoutParams.WRAP_CONTENT)); 
          } 



    } 

Merci