我在android中有一个EditText供用户输入他们的AGE.它设置为inputType = phone.我想知道是否有办法检查这个EditText是否为空.
我已经看过这个问题:检查EditText是否为空.但它没有解决inputType = phone的情况.
这些,我已经检查过并且不起作用:
(EditText) findViewByID(R.id.age)).getText().toString() == null
(EditText) findViewByID(R.id.age)).getText().toString() == ""
(EditText) findViewByID(R.id.age)).getText().toString().matches("")
(EditText) findViewByID(R.id.age)).getText().toString().equals("")
(EditText) findViewByID(R.id.age)).getText().toString().equals(null)
(EditText) findViewByID(R.id.age)).getText().toString().trim().length() == 0
(EditText) findViewByID(R.id.age)).getText().toString().trim().equals("")
and isEmpty do not check for blank space.
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.