I want to know how I would add a delay in a for loop in android studio. I want to change the background of a button to a certain colour then change it back. Then I want to go on to the next iteration of the loop.
I tried using handlers and the count down timer but I am not getting the desired effect. The loop will not pause and wait.
This is what I essentially want to do:
Random rand = new Random();
int [] pattern = new int[score + 1];
for (int j = 0; j < score+1; j++) {
pattern[j] = rand.nextInt(4);
//Here what I want is depending on the number,
I will change the colour and wait for a second then change it back all before the next iteration starts.
}