当我在代码行中将“大小”作为参数传递时,它显示没有工作......这是我的代码
final LayoutParams size=new LayoutParams(200, 25);//globally declared
private void Add() {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
TableLayout myTable = new TableLayout(AddParing.this);
EditText[][] myEditTexts = new EditText[2][2];
myTable.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
TableRow[] myRow = new TableRow[2];
for (int a = 0; a < 1; a++) {
myRow[a] = new TableRow(AddParing.this);
myRow[a].setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
for (int b = 0; b < 2; b++) {
myEditTexts[a][b] = new EditText(AddParing.this);
myEditTexts[a][b].setText("");
myEditTexts[a[b].setBackgroundResource(R.drawable.input_bar);
myEditTexts[a][b].setLayoutParams(size);
//myEditTexts[a][b].setHeight(15);
myRow[a].setGravity(Gravity.CENTER);
myRow[a].addView(myEditTexts[a][b]);
}
myTable.addView(myRow[a]);
}
TableLayout lin = (TableLayout) findViewById(R.id.tableLayout1);
lin.addView(myTable);
}
});
我想申请setlayoutparams()
. 那么我该如何申请才能正常工作?