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);
}
}
}
在上面的代码中,如果我删除行 edt.setLayoutParams... 正在显示编辑文本。但是,如果我设置他们没有显示的参数。知道可能是什么原因吗?