I'm designing a tic-tac-toe game.
The layout of the game is a LinearLayout (vertical) which has a button (reset), a TableLayout, and another button (submit). The TableLayout has TableRows, which in turn have Buttons.
The idea of my design is, when you hit submit, it sends the last pressed button (in the TableLayout) to the running game as "user input", and then after every move, the TableLayout updates to reflect the changes (the text changes to reflect which player owns that spot, disables the clickability of the button, and a splash of color because why not).
private void updateButton(Button button, char claimant)
{
button.setText(claimant == 'X' ? "X" : claimant == 'O' ? "O" : " ");
button.setTextColor(claimant == 'X' ? 0x500000 :
claimant == 'O' ? 0x332c2c :
button.getCurrentTextColor());
button.setClickable(claimant == ' ');
}
I have tried with adding these lines at the end of updateButton(), and nothing seems to work:
button.setWillNotDraw(false);
button.bringToFront();
button.invalidate();
button.postinvalidate();
What I need to do is - make Button disabled and make it appear as one.