I'm trying to compare the text entered in an EditText with an item in my ArrayList, but the condition is never true.
int aux=-1;
for (int i = 0; i < lista2.size(); i++) {
if (edContato.getText().equals(lista2.get(i))){
aux = i;
break;
}
}
if (rbExcluir.isChecked()) {
if(aux>=0){
principal();
lista2.remove(aux);
aplicarLista();
}
else {
dialogo.setTitle("Erro!");
dialogo.setMessage("Contato não encontrado!");
dialogo.setNeutralButton("OK", null);
dialogo.show();
excluir_alterar();
}
I'm a beginner in programming for Android and as far as I know, in Java this comparison would work. Am I letting anything happen? Does this situation require any other method of comparison?