You would need to write a custom Filter
class and implement the performFiltering
method yourself. This method takes a CharSequence
argument, which you can use to perform whatever String operations you need in order to generate a list of matches from your dataset (in your case, you could use String.contains
instead of String.startsWith
). The performFiltering
function is not run on the UI thread.
You then return your list of matches as a FilterResults
object, which contains an Object
values (your list of matches, probably an ArrayList
) and an int
count which is the size of your list of matches.
Finally, implement the publishResults
callback method, which returns once the worker thread has generated the list of matches, allowing you to call notifyDataSetChanged
on your AutoCompleteTextView's adapter so that it can display the results.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…