I created an HashMap<String, String>
that i populated beforehand.
And i want my AutoCompleteTextView
to tell me, as i'm typing if it's in the HashMap or not. Here's my code so far :
autocomplete.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(s.length() > 0){
if (map_clients.containsKey(s)){
Toast.makeText(context, "He's here", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(context, "He's not here", Toast.LENGTH_SHORT).show();
}
}
else {
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
It always tell me "He's not here" even when i type the text fully or when i select it from the autocompletion.