0
不禁用EditText
在執行onCreate()
。但是,當點擊CheckBox
時,該方法執行一次,然後再次停止執行。啓用或禁用EditTExt與CheckBOx不工作
任何人的幫助,以找到答案
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);
}
});
}
尤爾是正確的,但爵士當我初始化它的onCreate(),然後驗證一樣,如果(TextUtils.isEmpty(extraSpace.getText()的toString()) ){ extraSpace.setError(「請輸入額外的工作」); }然後在CheckBox Listner中的If()語句不工作並給我數字格式異常的錯誤 –