Help Center
Local Navigation
- Creating user interfaces
- Screens
- UI components
- Add a UI component to a screen
- Create a dialog box
- Creat a bitmap
- Create a button
- Create a list
- Create an alphanumeric drop-down list
- Create a text list that can be filtered
- Create a check box
- Create a radio button
- Create a date field
- Create a text field
- Create a read-only text field that allows formatting
- Create an editable text field that has no formatting and accepts filters
- Create an editable text field that allows special characters
- Create a password field
- Create a text field for AutoText
- Create a progress bar field
- Create a text label
- Create a list from which users can select multiple items
- Create a field to display a parent and child relationship between items
- Add a UI component to a screen
- Create a custom field
- Create a menu item
- Adding menu items to a BlackBerry device application
- Register a menu item
- Arrange UI components
- UI events
- Spell check
- Accessibility
- Notifying an assistive technology application when the UI changes
- UI changes that trigger a notification to an assistive technology application
- UI component states and properties
- Provide an assistive technology application with information about a UI change
- Provide an assistive technology application with information about text changes
- Provide an assistive technology application with access to information from a table
- Provide an assistive technology application with access to numeric values
- Allow an assistive technology application to receive notification of field changes
- Storing data
- Creating connections
- Network gateways
- Connections
- Wi-Fi connections
- Wireless access families
- Retrieve the wireless access families that a BlackBerry device supports
- Determine if a BlackBerry device supports multiple wireless access families
- Determine the wireless access family transceivers that are turned on
- Turn on the transceiver for a wireless access family
- Turn off the transceiver for a wireless access family
- Check if the Wi-Fi transceiver is turned on
- Check if the Wi-Fi transceiver is connected to a wireless access point
- Retrieve the status of the wireless access point or the active Wi-Fi profile
- Open a Wi-Fi socket connection
- Open a Wi-Fi HTTP connection
- Open a Wi-Fi HTTPS connection
- Managing applications
- Using custom messages and folders in the message list
- Creating a module for background processes
- Creating a module for the UI
- Create the module for background processes
- Start the module for background processes or the module for the UI
- Create an icon for a custom message
- Create a custom folder in the message list
- Send a notification when a custom folder changes
- Create an indicator for the number of messages in a custom folder
- Hide an indicator for a custom folder
- Remove an indicator for a custom folder
- Applications for push content
- Localizing BlackBerry device applications
- Controlling access to APIs and application data
- Check if a code signature is required
- Java APIs with controlled access
- Register to use controlled APIs
- Restrictions on code signatures
- Request a code signature
- Register a signature key using a proxy server
- Sign an application using a proxy server
- View the signature status for an application
- Using keys to protect APIs and data
- Protect APIs using code signing keys
- Protect runtime store data using code signing keys
- Protect persistent data using code signing keys
- Testing a BlackBerry device application
- Packaging and distributing a BlackBerry Java Application
- Preverify a BlackBerry device application
- Application distribution over the wireless network
- Wireless pull (user-initiated)
- Wireless push (server-initiated)
- Distributing BlackBerry Java Applications over the wireless network
- Distributing BlackBerry device applications with the BlackBerry Desktop Software
- Application distribution through a computer connection
- Distributing an application from a computer
- Create an application loader file
- Install a BlackBerry device application on a specific device
- Specifing supported versions of the BlackBerry Device Software
- Glossary
- Provide feedback
- Legal notice
BlackBerry Manuals & Help
>
Documentation for Developers
>
Java Development Guides and API Reference
>
Development Guide - BlackBerry Java Development Environment - 4.6.1
Create a text list that can be filtered
You can create an application that uses the KeywordFilterField class, included in the net.rim.device.api.ui.component package, to provide a UI field that consists of a single text input field and a list of selectable elements. A word that a BlackBerry® device user enters into the text input field filters the elements in the list. For more information about using the KeywordFilterField class,
see the KeywordFilterFieldDemo sample, included with the BlackBerry® Java® Development Environment version 4.3.1.
- Import the following classes:
- Import the net.rim.device.api.ui.component.KeywordProvider interface.
- Create variables. In the following code sample, CountryList extends the SortedReadableList class and implements the KeywordProvider interface.
private KeywordFilterField _keywordField; private CountryList _CountryList; private Vector _countries;
- To create a list of selectable text items, populate a vector with data from a text file.
_countries = getDataFromFile();
- Create an instance of a class that extends the SortedReadableList class.
_CountryList = new CountryList(StringComparator.getInstance(true),_countries);
- To specify the elements of the list, create a new instance of a KeywordFilterField object.
_keywordField = new KeywordFilterField();
- Invoke KeywordFilterField.setList().
_keywordField.setList(_CountryList, _CountryList);
- Set a label for the input field of the KeywordFilterFIeld.
_keywordField.setLabel("Search: "); - Create the main screen of the application and add a KeywordFilterField to the main screen.
KeywordFilterDemoScreen screen = new KeywordFilterDemoScreen(this,_keywordField); screen.add(_keywordField.getKeywordField()); screen.add(_keywordField); pushScreen(screen);
- To create a method that populates and returns a vector of Country objects containing data from text file, In the method signature, specify Vector as the return type.
public Vector getDataFromFile() { - Create and store a reference to a new Vector object.
Vector countries = new Vector();
- Create an input stream to the text file.
InputStream stream = getClass().getResourceAsStream("/Data/CountryData.txt"); - Read CRLF delimited lines from the input stream.
LineReader lineReader = new LineReader(stream);
- Read data from the input stream one line at a time until you reach the end of file flag. Each line is parsed to extract data that is used to construct Country objects.
for(;;) { //Obtain a line of text from the text file String line = new String(lineReader.readLine()); //If we are not at the end of the file, parse the line of text if(!line.equals("EOF")) {int space1 = line.indexOf(" "); String country = line.substring(0,space1); int space2 = line.indexOf(" ",space1+1); String population = line.substring(space1+1,space2); String capital = line.substring(space2+1,line.length()); // Create a new Country object. countries.addElement(new Country(country,population,capital)); } else { break; } } // end the for loop return countries; } - To add a keyword to the list of selectable text items,
invoke SortedReadableList.doAdd(element).
SortedReadableList.doAdd(((Country)countries.elementAt(i)).getCountryName()) ;
- To update the list of selectable text items, invoke KeywordFilterField.updateList().
_keywordField.updateList();
- To obtain the key word that a BlackBerry device user typed into the KeywordFilterField, invoke KeywordFilterField.getKeyword().
String userTypedWord = _keywordField.getKeyword();
Parent topic: UI components