I want to complete a task, which assigns the variable randomButton
a value. At the end, I want to check the value of randomButton
If it is something I don't like, I want to re do the task where I assign randomButton
a value.
I want to do this task:
int i = rng.nextInt(4); //Find random button from between 1-4
randomButton = buttons.get(i);
buttonBackground = randomButton.getBackground();
Log.v(TAG, "In the do");
and if
buttonBackground.equals(R.drawable.redcircle)
I want to try and do the task again. How do I achieve this...?
I have tried:
do {
int i = rng.nextInt(4); //Find random button from between 1-4
randomButton = buttons.get(i);
buttonBackground = randomButton.getBackground();
Log.v(TAG, "In the do");
}while(!buttonBackground.equals(R.drawable.redcircle));
But that is an infinite loop. So how do I repeat a task if the value is something I don't like?
By the way, buttons
is an arraylist with different image button objects. I want to see if the background of that imagebutton (randomButton) is redcircle. If it is, I want to go through the code again. If it isn't, thats great, and I can continue.