I put a setError, telling the user to fill in the form if it did not, but after filling it it was to clear the error, however, I did it using setErrorEnable (False) but it did not work.
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
showKeyboard(getContext());
//inicio calcular rpm
inputLayoutcormecial = (TextInputLayout) getView().findViewById(R.id.textinputcorm);
inputLayoutvcorte = (TextInputLayout) getView().findViewById(R.id.textinputVC);
veditTextCormecial = (EditText) getView().findViewById(R.id.editTextComercial);
veditTextVC = (EditText) getView().findViewById(R.id.editTextVC);
txtresultado = (TextView) getView().findViewById(R.id.textViewResultRPM);
Button botaocal = (Button) getView().findViewById(R.id.buttonCalc);
veditTextCormecial.requestFocus();
//clique do botao calc
botaocal.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (veditTextCormecial.getText().toString().matches("")) {
inputLayoutcormecial.setError(getString(R.string.campo_vazio));
veditTextCormecial.requestFocus();
return;
}
else if (veditTextVC.getText().toString().matches("")) {
inputLayoutvcorte.setError(getString(R.string.campo_vazio));
veditTextVC.requestFocus();
return;
}
else if (veditTextCormecial.getText().toString() != ""){
inputLayoutcormecial.setErrorEnabled(false);
}
else if (veditTextVC.getText().toString() != ""){
inputLayoutvcorte.setErrorEnabled(false);
}
else {
valorComer = Double.parseDouble(veditTextCormecial.getText().toString().replace(",","."));
valorVC = Double.parseDouble((veditTextVC.getText().toString()).replace(",","."));
vresultado = valorVC * 1000 / (3.14 * valorComer);
DecimalFormat formato = new DecimalFormat("#.##");
vresultado = Double.valueOf(formato.format(vresultado));
//exibir resultado
txtresultado.setText(vresultado.toString() + " RPM");
txtresultado.setVisibility(View.VISIBLE);
}
}
});
//fim calcular rpm