Oluwabusayo
Oluwabusayo

Reputation: 193

autocomplete search field for blackberry

I want to implement the an auto complete feature in an app am currently developing. I would have used the Blackberry native auto-complete field but I want the auto complete list to be gotten from a web server. This feature is being implemented in the search screen of google maps for blackberry.

Please can u give ideas on how to go about this?

Upvotes: 1

Views: 694

Answers (2)

WOUNDEDStevenJones
WOUNDEDStevenJones

Reputation: 5315

Great example from http://devblog.blackberry.com/2010/04/how-to-use-autocompletefield/

After getting your data back from the web server, store the searchable data as String[].

Then you just need the following code to make your AutoCompleteField work:

BasicFilteredList filterList = new BasicFilteredList();

//my query to sqlite database, yours could just be parsed from your webserver or whatever
String[] list = db.getSearchSuggestions(totalCount); 

filterList.addDataSet(1, list, "list", BasicFilteredList.COMPARISON_IGNORE_CASE);
final AutoCompleteField autoComplete = new AutoCompleteField(filterList);

Upvotes: 0

Eugen Martynov
Eugen Martynov

Reputation: 20140

I didn't try but I don't see any issue to do that. You need to add listener for the EditField - getEditField will help you. After getting list of suggestions, you pack them to BasicFilteredList and set it to AutoCompleteField with setFilteredList.

You should think also about implementation of case when network is not reachable.

Upvotes: 1

Related Questions