0

TextUtil.isEmpty() is always returning empty, even when the field is filled in the Android. Code snippet:

    if (TextUtils.isEmpty(name.getText().toString())) {

                completeNameEditText.setError("Empty field);
                Toast.makeText(getApplicationContext(), "Empty field", Toast.LENGTH_LONG).show();
                return; 
    }

The problem is that, even filling all the EditText with Strings, always points to the error: "Empty field".

Please, what to do to fix this?

Zain
  • 37,492
  • 7
  • 60
  • 84
Carl
  • 23
  • 5
  • What is the variable `name` referencing? Where and how do you assign it, can you share that part of code as well? As far as we know `name` might reference an `EditText` field that is hidden in your layout and you never input anything into it. – Ma3x Jan 07 '22 at 13:50
  • I already discovered the problem: it was a part of the code that it was disturbing. I just delete the code that was disturbing, and everything works fine. Thank you very much. You always helped a lot, Ma3x. Congratulations. – Carl Jan 07 '22 at 14:10
  • You are welcome. I am glad it helped you fix the issue. – Ma3x Jan 07 '22 at 14:12

0 Answers0