I want to use an AutoCompleteTextView in my activity and populate the data as the user types by querying a web API. How do I go about doing this?
Do I create a new class and override AutoCompleteTextView.performFiltering, or do I use a custom list adapter and provide a custom android.widget.Filter that overrides performFiltering?
Or is there a better way to obtain my end goal?
I’ve done something somewhat similar, but it was for the Quick Search box and it involved implementing a service, but I believe that’s not what I want to do here.
I came up with a solution, I don’t know if it is the best solution, but it appears to work very well. What I did was created a custom adapter that extends ArrayAdapter. In the custom adapter I overrode getFilter and created my own Filter class that overrides performFiltering. This starts a new thread so it doesn’t interrupt the UI. Below is a barebones example.
MyActivity.java
AutoCompleteAdapter.java