0
아니요 EditText
을 실행 중일 때 onCreate()
에서 실행 중지합니다. 그러나 CheckBox
을 클릭하면 메서드가 한 번 실행 된 다음 다시 실행을 중지합니다.CheckBOx가 작동하지 않는 상태에서 EditTExt를 사용 또는 사용하지 않음
사람은 대답
public void EXtraWorkCalc(){
extraworkCheck = (CheckBox)findViewById(R.id.workCheck);
extraworkCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (!compoundButton.isChecked()) {
extraSpace = (EditText) findViewById(R.id.extraWidthEtxt);
extraSpace.setEnabled(false);
extraSpace.setBackgroundColor(Color.LTGRAY);
} else
extraSpace.setEnabled(true);
extraSpace.setBackgroundColor(Color.WHITE);
}
});
}
YOR 오른쪽 경하지만 내가 좋아하는 유효성 검사 다음에서 onCreate에서 초기화() 및 AM 경우 경우 (TextUtils.isEmpty (extraSpace.getText의 toString()())) { extraSpace.setError ("추가 작업을 입력하십시오"); } CheckBox Listner의 If() 문이 작동하지 않고 Number Format Exception 오류를 표시합니다. –