addTextChangedListener에서 1 초를 어떻게 기다릴 수 있습니까? 다음 코드는 다음 오류를 제공합니다 : E/AndroidRuntime (1003) : java.lang.IllegalMonitorStateException : 스레드가 wait() 전에 스레드에서 잠기지 않은 객체개체를 잠그거나 모니터 소유자가되는 방법 (안드로이드)
Object wait() 메소드의 Android 참조에서이 메소드는 다음을 수행 할 수 있습니다. 이 객체의 모니터를 소유하는 thread에 의해서만 불려갑니다. thread가 모니터의 소유자가되는 방법에 대해서는 notify()를 참조하십시오.
Object의 notify()는 다음과 같습니다. 이 메서드는이 객체의 모니터를 소유 한 스레드에 의해서만 호출 할 수 있습니다. 스레드는 객체 모니터의 소유자가됩니다. • 객체의 동기화 된 메소드를 실행합니다. • 개체에 동기화되는 synchronized 문의 본문을 실행합니다. • 개체가 Class 유형 인 경우 동기화 된 정적 메서드를 실행합니다. 여기 데
하나의 문제는 : 나는 이해가 안 ...
내가 '일시 정지'두 번째 여기에 무엇을해야?
public class Spel extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.spel);
editText2 = (EditText) findViewById(R.id.editText2);
editText2.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
if (before==0) {
String v = s.toString();
if (v.equals("0") || v.equals("1") || v.equals("2") || v.equals("3") || v.equals("4") || v.equals("5") || v.equals("6") || v.equals("7") || v.equals("8") || v.equals("9")) {
try {
wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editText1.requestFocus();
editText1.setText(null);
editText2.setText(null);
int baanWorpScore = Integer.parseInt(v);
}
else {
// blijf wachten op goede invoer
editText2.setText(null);
}
}
}
});
sleep()이 지금 당장은 괜찮습니다. – user1837293