I want to check if a String (coming from an EditText) is part of a String Array and I need the index. I have got a TextWatcher added as TextChangedListener like the following:
inside Activity-Class:
private String[] randomSpanishWords = { "pueblo", "madre" };
private TextWatcher ETListener = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
int index = Arrays.asList(randomSpanishWords).indexOf(charSequence);
}
@Override
public void afterTextChanged(Editable editable) {
}
};
in onCreate():
editText1.addTextChangedListener(ETListener);
No matter what Im typing in the EditText, index is always -1. What am I missing?