I have a switch statment that changes the colour of certain buttons if true. The problem is that if more than one button is being lit, they all light at the same time. I need the code to pause after for a second after every case that is true.
public void PlaySequence() {
//loops through arraylist and changes the background colour of the buttons that has the corresponding number assigned i.e. red = 0, blue = 1 etc.
for (int i = 0; i < yourList.size(); i++) {
switch (Integer.parseInt(yourList.get(i).toString())) {
case 0:
redButton.setBackgroundColor(Color.RED);
revertButtonColour(0);
break;
case 1:
blueButton.setBackgroundColor(Color.BLUE);
revertButtonColour(1);
break;
case 2:
greenButton.setBackgroundColor(Color.GREEN);
revertButtonColour(2);
break;
case 3:
yellowButton.setBackgroundColor(Color.YELLOW);
revertButtonColour(3);
break;
}
}
Toast toast = Toast.makeText(this.getApplicationContext(), "Go!", Toast.LENGTH_SHORT);
toast.show();
}