user1534409
user1534409

Reputation: 325

How to filter data in AutoCompleteTextView from web API

Hey I'm using an AutoCompleteTextView in my android app the data that populates the textView is retrieved from a web API. the data is retrieved in JSON format and then added to a matrix cursor. the app then uses a cursor loader and a content provider to load data to the textview in the background. I would like to filter the data as I enter characters in the textview currently it loads all the data without filtering as I enter. Is there a way to filter the data in the cursor and have it loaded by the cursorloader without having to request the web API again

Upvotes: 2

Views: 825

Answers (1)

Uncaught Exception
Uncaught Exception

Reputation: 2179

I think your approach is incorrect. Why do you need to save the received data, particularly given that that data is intermittent and the user is still typing? Also you need to: 1) start Data fetching only when a user pauses typing (to prevent a bunch of requests to a server after every entered character) 2) Suggestions should be shown only if the user enters a string of some minimum length (no reason to start data fetching for string of 2 or 3 characters)

Check out this explanation from Alex Melnykov about how he used 'AutoCompleteTextView With Suggestions From a Web Service' for his app Booktracker.

Upvotes: 2

Related Questions