I am trying to set the background color of the ImageView in a certain amount of time (pauses between each color switch) based on certain criteria (such as string = "a" or "b"). My problem is that I can not make the whole application wait for one change until it moves to the next, so for the user it just looks like the color starts, and then the last color.
I tried CountDownTimers (which just keep running while another timer is running), handlers (postDelayed (null, 5000)), Thread.Sleeps, etc.
Here is an example of what I'm trying to do:
Set the color in ImageView to red
sleep for 500 ms
for(int i = 0; i < stringArray.length; i++){ if(stringCompare = "a") { Set color on ImageView to blue sleep for 500ms } else if(stringCompare = "b") { Set color on ImageView to blue sleep for 1000ms } Set color on ImageView to red sleep for 500ms }
I know such a crazy person, but I tried all of the above methods that I could think of without success, actually making the program wait, but not completely stopping it.
Thanks.
source share