Help Center

Local Navigation

Autocomplete text field

You can use an autocomplete text field to predict what a BlackBerry® device user wants to type, and display a word or phrase before the user types it completely.

When you create an AutoCompleteField object, you must associate a BasicFilteredList object with it. The BasicFilteredList maintains references to data objects that are compared with to produce the list of words and phrases. You can configure which fields in the data objects are compared with and which fields are displayed when a match is found. For example, you can compare the text that the user types with the value of the DATA_FIELD_CONTACTS_BIRTHDAY field in the DATA_SOURCE_CONTACTS data source, and return the value of the corresponding DATA_FIELD_CONTACTS_NAME_FULL field.

There are four types of data that you can bind to a BasicFilteredList to use with an AutoCompleteField.

You can specify the set of strings to compare with in one of the following ways:

  • an array of literal strings
  • an array of objects that support toString()
  • data sources on a BlackBerry device, such as contacts, memos, tasks, and various types of media files
  • an array of objects and an array of strings with corresponding indexes

By default, the autocomplete text field displays the set of strings that is returned by the comparison process in a drop-down list. You can configure the appearance of this list by specifying style flags when you create the autocomplete text field. You can change how the list appears and how users can interact with the list.

Previous topic: Create a search field

Was this information helpful? Send us your comments.