Could anyone explain 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 this way it does not 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();
}
}
});