* Creates a new AutoCompleteFieldDemoScreen object
*/
AutoCompleteFieldDemoScreen() {
setTitle("Auto Complete Field Demo");
add(new LabelField("Type in a field to search"));
add(new SeparatorField());
// Create the filtered lists
_filteredListContacts = new BasicFilteredList();
final BasicFilteredList filteredListMedia = new BasicFilteredList();
final BasicFilteredList filteredListMonths =
new BasicFilteredList();
// Add data source for contacts
_filteredListContacts.addDataSource(0,
BasicFilteredList.DATA_SOURCE_CONTACTS,
BasicFilteredList.DATA_FIELD_CONTACTS_NAME_FULL
| BasicFilteredList.DATA_FIELD_CONTACTS_COMPANY
| BasicFilteredList.DATA_FIELD_CONTACTS_EMAIL,
BasicFilteredList.DATA_FIELD_CONTACTS_NAME_FULL,
BasicFilteredList.DATA_FIELD_CONTACTS_EMAIL, -1, null,
BasicFilteredList.COMPARISON_IGNORE_CASE);
// Add data source for music
filteredListMedia.addDataSource(0,
BasicFilteredList.DATA_SOURCE_MUSIC,
BasicFilteredList.DATA_FIELD_MUSIC_SONG,
BasicFilteredList.DATA_FIELD_MUSIC_ARTIST
| BasicFilteredList.DATA_FIELD_MUSIC_ALBUM
| BasicFilteredList.DATA_FIELD_MUSIC_SONG,
BasicFilteredList.DATA_FIELD_MUSIC_SONG, -1, null,
BasicFilteredList.COMPARISON_IGNORE_CASE);
// Add data source for pictures
filteredListMedia.addDataSource(0,
BasicFilteredList.DATA_SOURCE_PICTURES,
BasicFilteredList.DATA_FIELD_PICTURES_TITLE,
BasicFilteredList.DATA_FIELD_PICTURES_TITLE, -1, -1, null,
BasicFilteredList.COMPARISON_IGNORE_CASE);
// Add data source for videos
filteredListMedia.addDataSource(0,
BasicFilteredList.DATA_SOURCE_VIDEOS,
BasicFilteredList.DATA_FIELD_VIDEOS_TITLE,
BasicFilteredList.DATA_FIELD_VIDEOS_TITLE, -1, -1, null,
BasicFilteredList.COMPARISON_IGNORE_CASE);
// Add data set for months
final String[] months =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October",
"November", "December" };
filteredListMonths.addDataSet(0, months, "Month",
BasicFilteredList.COMPARISON_IGNORE_CASE);
// Create AutoCompleteFields
final AutoCompleteField autoCompleteFieldContacts =
new AutoCompleteField(_filteredListContacts,
AutoCompleteField.LIST_STATIC
| AutoCompleteField.LIST_DROPDOWN);
final AutoCompleteField autoCompleteFieldMedia =
new AutoCompleteField(filteredListMedia,
AutoCompleteField.LIST_STATIC
| AutoCompleteField.LIST_SHOW_DATA_SET_NAME
| AutoCompleteField.LIST_DROPDOWN);
final AutoCompleteField autoCompleteFieldMonths =
new AutoCompleteField(filteredListMonths,
AutoCompleteField.LIST_STATIC
| AutoCompleteField.LIST_DROPDOWN);
// Add the AutoCompleteFields to the screen
add(new LabelField("Choose a contact"));
add(autoCompleteFieldContacts);
add(new LabelField("Choose media"));
add(autoCompleteFieldMedia);
add(new LabelField("Choose a month"));
add(autoCompleteFieldMonths);
}