If EditText.getText().ToString() == “” dont work; [duplicate]

与世无争的帅哥 提交于 2019-11-28 14:52:02

Change it to

if(editText.getText().toString().equals("")){

In Java .equals() is used to compare if they have the same value and "==" is used to determine if they reference the same object.

An even better way is to use

if("".equals(editText.getText().toString())){

because this will protect against a NPE.

Java String Docs

Do not use == with Strings use equals()

if(editText.getText().toString().equals("")){
   editTextBenefaction.setText("0");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!