Я делаю игру Tic Tac Toe. И я использовал кнопки для крестиков-ноликов и динамически устанавливал макет таблицы. Проблема в том, что я не могу установить свойство фона кнопки. Мой код здесь.
TableLayout table = (TableLayout) findViewById(R.id.tableLayout1);
table.removeAllViewsInLayout();
int id = 0;
for (int f = 0; f < board_size; f++) {
TableRow tr = new TableRow(this);
for (int c = 0; c < board_size; c++) {
Button b = new Button(this);
b.setId(id);
b.setTextSize(15.0f);
//below code assign color to whole table background
//b.setBackground(Color.WHITE);
b.setOnClickListener(this);
id++;
tr.addView(b, screenWidth / board_size, screenWidth / board_size);
}
table.addView(tr);
}
Пожалуйста, помогите мне. Заранее спасибо.