0
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    LinearLayout ll=(LinearLayout)findViewById(R.id.linearlayout);



   for(int k=0;k<10;k++)    
   {    TableRow tr=new TableRow(this);
       tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); 
        tr.setId(k);

    for(int s=0;s<10;s++)
         {
         EditText edt=new EditText(this);
         Log.i("SS","setting layout params for textview "+s+k);
         edt.setText("abc "+s+k+"  ");


        edt.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        ViewGroup.LayoutParams p=edt.getLayoutParams();

         Log.i("SS","edt params "+p.height +" "+p.width);
        tr.addView(edt);
         }
   ll.addView(tr);
   }



}

}

In the above code if i remove the line edt.setLayoutParams... the edit Texts are showing. But if i set the their params they are not showing. Any idea what could be the reason?

Gaurav
  • 667
  • 2
  • 13
  • 28

1 Answers1

0

Try out This...

TableRow tr = new TableRow(this);  
TableLayout.LayoutParams tableRowParams=
  new TableLayout.LayoutParams
  (TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);


tableRowParams.setMargins(10, 10, 10, 10);

tr.setLayoutParams(tableRowParams);

Hope this will help u out...

Richa
  • 3,165
  • 1
  • 22
  • 26