I am new to Android Development and I am trying to make a game. I have a 3x3 grid of imagebuttons and a play button. When the user clicks the play button, a number of buttons should light up and then turn off. That works fine. Now I am trying to have the buttons light up and turn off one by one. So if comp_blocks contains [1, 3, 2] button 1 would light up, then turn off, then button 3 would light up.... etc. What is the best way to do this? I would like the button to stay lit for a half a second.
Edit: To be clear, I want each one to light up and go out all on one press of the button. Press button, display 1, turn off 1, display 3, turn off 3. Next time the user presses the button, a new sequence would show.
//Create pattern in comp_blocks
for(int i = 0; i < move_num+2; i++){
comp_blocks.add(rand.nextInt(9) + 1);
}
//Display pattern
ListIterator<Integer> itr = comp_blocks.listIterator();
while (itr.hasNext()) {
final Integer button_show = itr.next();
switch (button_show){
case 1:
button1.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 2:
button2.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 3:
button3.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 4:
button4.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 5:
button5.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 6:
button6.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 7:
button7.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 8:
button8.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
case 9:
button9.setBackgroundColor(getResources().getColor(R.color.garnet));
break;
}