0
兩個LinearLayout
linearfirstRow
和linearsecondRow
都有四個按鈕each.First線性佈局工作和第二個佈局不顯示。多線性佈局不工作
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
linearfirstRow=new LinearLayout(this);
linearfirstRow.setOrientation(LinearLayout.HORIZONTAL);
linearfirstRow.setId(1);
LinearLayout.LayoutParams Layoutparam1 = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,25);
linearfirstRow.setLayoutParams(Layoutparam1);
setContentView(linearfirstRow);
linearsecondRow=new LinearLayout(this);
linearsecondRow.setOrientation(LinearLayout.HORIZONTAL);
linearsecondRow.setId(2);
linearsecondRow.setLayoutParams(Layoutparam1);
btn_1=new Button(this);
btn_1.setLayoutParams(Layoutparam1);
btn_2=new Button(this);
btn_2.setLayoutParams(Layoutparam1);
btn_3=new Button(this);
btn_3.setLayoutParams(Layoutparam1);
btn_4=new Button(this);
btn_4.setLayoutParams(Layoutparam1);
btn_5=new Button(this);
btn_5.setLayoutParams(Layoutparam1);
btn_6=new Button(this);
btn_6.setLayoutParams(Layoutparam1);
btn_7=new Button(this);
btn_7.setLayoutParams(Layoutparam1);
btn_8=new Button(this);
btn_8.setLayoutParams(Layoutparam1);
linearfirstRow.addView(btn_1);
linearfirstRow.addView(btn_2);
linearfirstRow.addView(btn_3);
linearfirstRow.addView(btn_4);
buttons are --> linearsecondRow.addView(btn_5);
notdisplayed linearsecondRow.addView(btn_6);
linearsecondRow.addView(btn_7);
linearsecondRow.addView(btn_8);
最後部分添加這個你爲什麼不通過XML biuld的UI顯示? – 2014-09-02 08:46:38