4
Could someone explain to me why this happens? My apk only works right if I put denial and do something:
public class Main2Activity extends AppCompatActivity {
    private EditText nome, teste, cpf;
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        nome = (EditText) findViewById(R.id.editnome);
        teste = (EditText) findViewById(R.id.editcopia);
        cpf = (EditText) findViewById(R.id.editcpf);
        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!nome.getText().toString().trim().equals("") && !teste.getText().toString().trim().equals("") && !cpf.getText().toString().trim().equals("")) {
                    Toast.makeText(getApplicationContext(), "Não vazio", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getApplicationContext(), "Vazio", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
Now if I put it that way it doesn’t work because?:
button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (nome.getText().toString().trim().equals("") && teste.getText().toString().trim().equals("") && cpf.getText().toString().trim().equals("")) {
            Toast.makeText(getApplicationContext(), "Vazio", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getApplicationContext(), "Não vazio", Toast.LENGTH_SHORT).show();
        }
    }
});
I was going to supplement mine with the
||, now I don’t need– bfavaretto
Depends he considers an empty space as something in there? the question of isEmpty...
– Aline
@gonz I think not, then I would have to use the
trim()same. You need to see if the data needstrim().– Maniero