tags:

views:

275

answers:

3

I've tried null and empty string, any other ideas?

+2  A: 

If it's empty, this will work:

if(mEditText.getText().toString().equals("")) {
    // stuff to run when it's empty
}

Even if it's empty, getText() will still return an Editable, so if you were trying to do this:

if(mEditText.getText().equals("")) {
    // stuff
}

It most certainly wasn't working.

synic
+2  A: 

You can use TextUtils.isEmpty( mEditText.getText().toString() ). It will return true if its empty/null.

Karan
+2  A: 

No other possibility.

getText, infact, will never return null. It returns CharSequence whose contents may be empty.

Instead of doing getText().toString().equals("") or vice-versa, it may be faster to do getText().length() == 0

MasterGaurav