我有这样的功能:设置按钮文本不起作用
public void setRandomValuesToButtons() {
for(i=0;i<Rows; i++){
for(j=0;j<Columns; j++){
if (i==2 && j==1){
continue;
}
// Random rand = new Random(); rand global variable
rand_int = rand.nextInt(8);
buttonsTable[i][j]=new Button(this);
buttonsTable[i][j].setText(Integer.toString(rand_int));
buttonsVals[i][j]=rand_int;
}
}
但我的按钮并没有改变他们的文本。为什么?
这是什么时候运行?在调用setRandomValuesToButtons()之前调用setRandomValuesToButtons(),我初始化每个按钮,如下所示: buttonsTable [0] [1] =(Button)findViewById(R.id.B_l0c1); – fredley