查看各種示例,下面是將視圖添加到佈局的正確方法。但是,沒有任何東西顯示給我。我假設它與佈局選項有關,但我是新的,所以我不知道缺少什麼。以編程方式將按鈕添加到佈局但未出現
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.songs_layout);
LinearLayout layout = (LinearLayout) View.inflate(this, R.layout.songs_layout, null);
Button myButton = new Button(this);
myButton.setText("Change View");
myButton.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
layout.addView(myButton);
}