I have implemented AutoCompleteTextView as follows:
MainActivity.java
...
public static String[] myData=new String[
The default implementation of the filter for ArrayAdapter is searching the beginning of words (separated by space), I mean it uses startsWith. You will need to implement an ArrayFilter which uses contains together with startsWith.
Your issue will be solved by the following steps:
ArrayAdapter.java file from hereCustomArrayAdapter.java, for example).In the file, you will find a private class ArrayFilter. Then, add valueText.contains(prefixString) and words[k].contains(prefixString) as the following:
if (valueText.startsWith(prefixString) || valueText.contains(prefixString)) {
newValues.add(value);
} else {
final String[] words = valueText.split(" ");
final int wordCount = words.length;
// Start at index 0, in case valueText starts with space(s)
for (int k = 0; k < wordCount; k++) {
if (words[k].startsWith(prefixString) || words[k].contains(prefixString)) {
newValues.add(value);
break;
}
}
}
Use that customized ArrayAdapter for your AutoCompleteTextView
And here is the result screenshot:
Hope this helps!