I've implemented the MultiAutoCompleteTextView and everything is working fine but now I want to suggestions at any point the user press the first character of the suggested words. Basically the suggestions appears at the start of the text and when the last character in the text is ","
So, this is my words list:
{"/Bag","/Carton","/Kg","/20cm"}
And I want suggestions to appear if the user press something like: 567/
I've tried overriding the enoughFilter() in my custom class like this:
public static Tokenizer mTokenizer = new MultiAutoCompleteTextView.CommaTokenizer();
@Override
public boolean enoughToFilter() {
Editable text = getText();
int end = getSelectionEnd();
if (end < 0 || mTokenizer == null) {
return false;
}
int start = mTokenizer.findTokenStart(text, end);
if (end - start >= getThreshold() || text.charAt(text.length()-1) == '/') {
return true;
} else {
return false;
}
}
But this doesn't work at all and it crashes my code. Anyone with the idea?
And finally I was able to achieve this by overriding enoughFilter(), performFiltering() and replaceText() in my custom class.
So, for anyone who wants to implement something similar, check my code below:
If you want more customization, check the source code HERE. That helps me a lot.