-4

I have some EditText which is of "numberDecimal", and One Button. When user clicks on button, data goes to Database. So how to check EditText is empty or not. I am getting error when I try to parse the EditText.

Hardik Trivedi
  • 5,677
  • 5
  • 31
  • 51

1 Answers1

0

To check an edittext is empty:

EditText ed = (EditText) findViewById(R.id.ed);
age = ed.getText().toString();
if (age.matches("")) {
    Toast.makeText(this, "Empty", Toast.LENGTH_SHORT).show();
    return;
}

You can also use equals() instead of matches()

kgandroid
  • 5,507
  • 5
  • 39
  • 69