Want to display an error message if the value is NULL or VOID if EditText is empty but apps keeps crashing
问题 public void add(View v) { EditText first=findViewById(R.id.first),second=findViewById(R.id.second); double f=Double.parseDouble(first.getText().toString()); double s=Double.parseDouble(second.getText().toString()); TextView result=findViewById(R.id.result); double r; if(TextUtils.isEmpty(first.getText().toString())) { first.setError("This field can't be empty"); } else if(TextUtils.isEmpty(second.getText().toString())) { second.setError("This field can't be empty"); } else { r = f + s; result