Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 84
Registered: ‎01-10-2013
My Device: Bold 9900
My Carrier: China Unicom
Accepted Solution

A strange problem of KeywordFilterField

[ Edited ]
package mypackage;

import javax.microedition.lcdui.Font;
import net.rim.device.api.collection.util.SortedReadableList;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.util.Comparator;
import net.rim.device.api.util.StringUtilities;

public final class KeywordSearchScreen extends MainScreen
{
     public static final String[] VendorID={"-1","0","1"};
     public static final String[] VendorName={"非正常销售、非正常工作状态手机","EDT工程机","DVT测试机"};
KeywordFilterField _keywordFilterField; CountryList _countryList; static final int ListRowHeightOffset=13; public KeywordSearchScreen() { setTitle("Keyword Search"); _countryList = new CountryList(); for(int i=0; i<=VendorID.length-1; i++) { _countryList.addElement(new Country(VendorID[i] + ": " + VendorName[i])); } _keywordFilterField = new KeywordFilterField(); _keywordFilterField.setSourceList(_countryList, _countryList); setTitle("View all vendors"); add(_keywordFilterField); } } class CountryList extends SortedReadableList implements KeywordProvider { public CountryList() { super(new CountryListComparator()); } void addElement(Object element) { doAdd(element); } public String[] getKeywords(Object element) { if(element instanceof Country) { return StringUtilities.stringToWords(element.toString()); } return null; } final static class CountryListComparator implements Comparator { public int compare(Object o1, Object o2) { if (o1 == null || o2 == null) throw new IllegalArgumentException("Cannot compare null countries"); return o1.toString().compareTo(o2.toString()); } } } class Country { private String _countryName; public Country(String countryName) { _countryName = countryName; } public String toString() { return _countryName; } }

 

This is my code by using KeywordFilterField class, in the begining it was very good to show the UI, but now, i just got an UI that a KeywordFilterField without TextFiled, only shown a list for me, and the search function is correctly, i was so sad, anybody can help?

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: A strange problem of KeywordFilterField

I am not 100% clear on what you are asking, but try the following:

 

Between these two lines:

setTitle("View all vendors");
add(_keywordFilterField);

 

insert the following line:

add(_keywordFilterField.getKeywordField());

 

The three lines should now look like:

 

setTitle("View all vendors");
add(_keywordFilterField.getKeywordField());
add(_keywordFilterField);

Developer
Posts: 84
Registered: ‎01-10-2013
My Device: Bold 9900
My Carrier: China Unicom

Re: A strange problem of KeywordFilterField

thanks guy, it was really my mistake. i was used setTitle(String) to instead of setTitle(getKeywordField()), so i got this trouble.

thanks again!