public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.rollDice:
Random ranNum = new Random();
int number = ranNum.nextInt(6) + 1;
diceNum.setText(""+number);
sum = sum + number;
for(i=0;i<8;i++){
for(j=0;j<8;j++){
int value =(Integer)buttons[i][j].getTag();
if(value==sum){
inew=i;
jnew=j;
buttons[inew][jnew].setBackgroundColor(Color.BLACK);
//I want to insert a delay here
buttons[inew][jnew].setBackgroundColor(Color.WHITE);
break;
}
}
}
break;
}
}
배경 변경 사이의 명령 사이에 지연을 설정하고 싶습니다. 스레드 타이머를 사용하고 run and catch를 사용해 보았습니다. 그러나 작동하지 않습니다. 나는 이것을 시도했다
Thread timer = new Thread() {
public void run(){
try {
buttons[inew][jnew].setBackgroundColor(Color.BLACK);
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
timer.start();
buttons[inew][jnew].setBackgroundColor(Color.WHITE);
그러나 검은 색으로 만 바뀌고 있습니다.