Search code examples
androidandroid-edittext

How do I check if my EditText fields are empty?


I have 5 EditTexts in android. I would like to know if I could check if all 5 EditTexts are null. Is there any way to do this??


Solution

  • I did something like this once;

    EditText usernameEditText = (EditText) findViewById(R.id.editUsername);
    sUsername = usernameEditText.getText().toString();
    if (sUsername.matches("")) {
        Toast.makeText(this, "You did not enter a username", Toast.LENGTH_SHORT).show();
        return;
    }