There are many buttons for activating: button1, button2 ... button30 with id buttonCard1, buttonCard2, etc. There is a SQL base for 30 positions, that is, each button has a value of 1.2 or 3. The task is this: through the for loop, move these values from the base in order and set the background for those buttons that are set to 1. I get the string value id, but I don’t understand how to apply a background to it.
for(int i = 1; i <= 30; i++){ userCursor = db.rawQuery("select * from " + DbDataHelper.TABLE + " where " + DbDataHelper.COLUMN_ID + "=?", new String[]{String.valueOf(i)}); color = userCursor.getInt(3); if(color == 1){ String id = "R.id.buttonCard" + i; //На полученный id нужно применить background ???(Integer.valueOf(id)).setBackgroundColor(getResources().getColor(R.color.colorButton1)); } }