I have an array of buttons in my Android app. I want pressing a button to cause a different button to turn white. I have code like this:
final Button [][] button = new Button[5][3];
for(int i = 0; i < tableRow.length; i++) {
for(int j = 0; j < button[i].length; j++) {
button[i][j] = new Button(this);
button[i][j].getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0xFF000000));
}
}
button[0][0].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
button[0][0].getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0x00FFFFFF));
}
});
This works fine, but it turns button[0][0] white when it is pressed, while I want pressing button[0][0] to turn button[0][1] white. If I change it to this:
button[0][0].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
button[0][1].getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0x00FFFFFF));
}
});
nothing happens when I press button[0][0]. Why?