我正在尝试显示按钮。但是下面的代码不起作用。不幸的是,应用程序已停止。需要额外的代码吗?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
String[] values = { "GOogle", "Yahoo", "Twi" };
Button[] b = new Button[values.length];
for (int i = 1; i <= values.length; i++) {
b[i].setText(values[i]);
layout.addView(b[i]);
}
setContentView(layout);
}