Reset class

Asked

Viewed 29 times

0

I have to check the consistency of some fields in my application, but I can’t get the process to stop so that the user enters the correct information. The way I put it, the error message is displayed but the processing continues, see the commands below. What should I do?

    InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
    if (rendim.getText().toString().isEmpty())
    {
        rendim.setError("Preencha o salário");
        rendim.requestFocus();
        imm.showSoftInput(rendim, InputMethodManager.SHOW_IMPLICIT);
    }
    else
    {
        objVal_or = new Val_or();
        rendimento = objVal_or.va_lor(rendim.getText().toString());
        if (rendimento <= 0)
        {
            rendim.setError("Salário zerado");
            rendim.requestFocus();
            imm.showSoftInput(rendim, InputMethodManager.SHOW_IMPLICIT);
        }
    }
  • In what situation does the process continue, when should it stop? I do not understand what is really happening. If the field is not filled rendim empty and the message Preencha o salário If the rendim is completed and is <=0appears Salário zerado

  • Solved, missing the Return command at the end of the IF block, I switched to a simpler form: if (rendim.gettext().toString().isEmpty()) { rendim.setError("Fill in salary"); rendim.requestFocus(); Return; } Else {&#xA; objVal_or = new Val_or();&#xA; rendimento = objVal_or.va_lor(rendim.getText().toString());&#xA; if (rendimento <= 0)&#xA; {&#xA; rendim.setError("Salário zerado");&#xA; rendim.requestFocus();&#xA; Return; } }

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.