try 블록이 먼저 실행되는 이유는 색상을 먼저 변경 한 다음 5000ms 동안 잠자기해야합니다. 나는 색상 변경 전에 시스템이 잠든 것을 의미합니다. 또한 업데이트를 수행하는 동일한 스레드 (스윙에 EDT 소위) 개인 OnClickListener를 CheckAnswer = 새로운 OnClickListener를() {당신은 GUI의 주 스레드에서 작업하는왜 Sleep이 먼저 실행되고 위의 코드가 android에서 실행됩니까?
public void onClick(View arg0) {
// TODO Auto-generated method stub
disableButtons();
Button incoming=(Button) arg0;
if(incoming.getText().toString().equals(Q.getAnswer()))
{
incoming.setBackgroundColor(Color.GREEN);
correct++;
score+=15;
}
else
{
incoming.setBackgroundColor(Color.RED);
wrong++;
if(C1.getText().toString().equals(Q.getAnswer()))
C1.setBackgroundColor(Color.GREEN);
else if(C2.getText().toString().equals(Q.getAnswer()))
C2.setBackgroundColor(Color.GREEN);
else if(C3.getText().toString().equals(Q.getAnswer()))
C3.setBackgroundColor(Color.GREEN);
modifyScore();
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
questionGenerator();
}
};`
나는 shure가 아니지만 색상을 변경 한 후에 요소를 다시 그려야 할 수도 있습니다. – PKeidel
왜 UI 스레드를 잠자고 싶습니까? –