0
EditText
を実行中に無効にすると、onCreate()
に実行されます。しかし、CheckBox
をクリックすると、このメソッドは一度実行され、再度実行を停止します。CheckBOxが有効でない状態でEditTExtを有効または無効にする
誰もがあなたがcheckBox
setOnCheckedChangeListener
内部に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);
}
});
}
ヨールは右卿ですが、私のような検証、その後のonCreateでそれを初期化()としていたときにあれば(TextUtils.isEmpty(extraSpace.getText()のtoString()) ){ extraSpace.setError( "余分な仕事を入力してください"); } CheckBox ListnerのIf()ステートメントが動作していないため、数値書式例外のエラーが表示される –