layout = new LinearLayout(this);
addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Button btn = new Button(this);
btn.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
btn.setText("button");
layout.addView(btn);
Button btn1 = new Button(this);
btn1.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
btn1.setText("button");
layout.addView(btn1);
이 레이아웃에 뷰를 추가 할 때마다 그 중 하나만 표시되기 때문에 뭔가를 놓쳐 야합니다.LinearLayout은 하나의 뷰만 추가 할 수 있도록 허용합니다.
y는 u는 추가하지 않습니다를 변경 xml을 통한 버튼? – Shaireen