我创建了一组按钮,当我给每个按钮设置背景图像时,就变成不可点击的了。为什么会这样呢?下面是我的代码:
LinearLayout layoutVertical = (LinearLayout) findViewById(R.id.liVLayout);
LinearLayout rowLayout=null;
Button[][] buttons = new Button[6][7];
LayoutParams param = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT,1);
for (int i = 0; i<6; i++)
{
rowLayout = new LinearLayout(this);
rowLayout.setWeightSum(7);
layoutVertical.addView(rowLayout,param);
for(int j=0;j<7;j++)
{
buttons[i][j]=new Button(this);
buttons[i][j].setText("1");
buttons[i][j].setBackgroundResource(R.drawable.but_blue_clicked);
rowLayout.addView(buttons[i][j],param);
buttons[i][j].setClickable(true);
}
}
}