BlackBerry SDK 5.0提供输入过滤,输入自动完成的功能。
- BasicFilteredList - 创建过滤列表
- AutoCompleteField - 创建输入自动完成Field
// 首先创建过滤列表
BasicFilteredList filterList = new BasicFilteredList();
// 自动完成内容
String[] days = {"Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday","Sunday"};
// 设置过滤内容
int uniqueID = 0;
filterList.addDataSet(uniqueID,days,"days",BasicFilteredList.COMPARISON_IGNORE_CASE);
// 创建输入自动完成功能, 设置自动完成标准
AutoCompleteField autoCompleteField = new AutoCompleteField(filterList);
add(autoCompleteField);
以下是输入自动完成在9700上的截图:
源代码如下:
/*
* AutoCompleteFieldDemo.java
*
* Copyright �1998-2010 Research In Motion Ltd.
*
* Note: For the sake of simplicity, this sample application may not leverage
* resource bundles and resource strings. However, it is STRONGLY recommended
* that application developers make use of the localization features available
* within the BlackBerry development platform to ensure a seamless application
* experience across a variety of languages and geographies. F