1
I put a setError , warning the user to fill in the form if they had not, however after it filled out was to disappear the error, but continues, I did 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
Worked perfectly
– Igor Oliveira