Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6844755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:25:01+00:00 2026-05-27T00:25:01+00:00

I am creating a ListField. in each row of I am adding a image

  • 0

I am creating a ListField. in each row of I am adding a image and 3 labelfield.
Can any one tell me how to create a keywordfilterField for this…
Thanks in advance
I am new to blackberry.
Little code will help me alot
This is my code for creating a custom list

class CustomListField extends ListField implements ListFieldCallback
{
String type;
int DISPLAY_WIDTH = Display.getWidth();
int DISPLAY_HEIGHT = Display.getHeight();
Vector mItems = new Vector();
Vector mine = new Vector();
Vector three= new Vector();     
// SizedVFM mListManager = new SizedVFM(DISPLAY_WIDTH, DISPLAY_HEIGHT - 40);
Bitmap searchresult = Bitmap.getBitmapResource("res/searchresult.png");
HorizontalFieldManager hfManager;
Bitmap image ,image1;
int z = this.getRowHeight();
CustomListField(String text1,String text2,String type) 
{
    for (int i = 1; i < 31; i++) 
    {      
        mItems.addElement(text1 +String.valueOf(i));
        mine.addElement("    "+text2);
        three.addElement("31");
    }
    this.type=type;
    this.setRowHeight((2*z));       
    this.setCallback(this);
    this.setSize(20);
    //mListManager.add(mListField);
    //add(mListManager);           
}
public void drawListRow(ListField field, Graphics g, int i, int y, int w) 
{
    // Draw the text.
    image = Bitmap.getBitmapResource("res/searchresult.png");
    String text = (String) get(field, i);
    String mytext = (String)mine.elementAt(i);
    String urtext=(String)three.elementAt(i);
    g.drawBitmap(0, y, image.getWidth(),image.getHeight(), image, 0, 0);
    g.drawText(text, image.getWidth(), y, 0, w);
    g.setColor(Color.GRAY);
    g.drawText(mytext, image.getWidth(), y+getFont().getHeight(), 0, w);
    g.drawText(urtext,Graphics.getScreenWidth()*7/8,y,0,w);
    if (i != 0) 
    {
          g.drawLine(0, y, w, y);
    }       
}

public Object get(ListField listField, int index) 
{
    return mItems.elementAt(index);
}

public int getPreferredWidth(ListField listField) 
{
    return DISPLAY_WIDTH;
}

public int indexOfList(ListField listField, String prefix, int start) 
{
    return 0;
}
protected boolean touchEvent(TouchEvent message) 
{
    // If click, process Field changed
    if ( message.getEvent() == TouchEvent.CLICK ) 
    {
        if(type.equals("Stops"))
            UiApplication.getUiApplication().pushScreen(new SearchScreen("Services")); 
        else if(type.equals("Services"))
            UiApplication.getUiApplication().pushScreen(new SearchScreen("Stops")); 
        return true;
    }
    return super.touchEvent(message);
}
}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:25:01+00:00Added an answer on May 27, 2026 at 12:25 am

    The problem with KeywordFilterField is that it uses internally its own ListField, so I think it is going to be difficult to customize. If you wanted to use it as it is provided, you’ll have to use it as follows:

        //KeywordFilterField contains a ListField to display and a search edit field to type in the words
        KeywordFilterField keywordFilterField = new KeywordFilterField();  
    
        //Instantiate the sorted collection:
        CustomList cl = new CustomList(mItems);
    
        //Pass the custom collection
        keywordFilterField.setSourceList(cl, cl); 
    
    
        //Now you have to add two fields: first the list itself
        myManager.add(keywordFilterField);
        //And the search field, probably you'd want it at top: 
        myScreen.setTitle(keywordFilterField.getKeywordField());
    

    You’ll have to implement a custom sortable collection to hold the items you wan’t to display:

        class CustomList extends SortedReadableList implements KeywordProvider {
            //In constructor, call super constructor with a comparator of <yourClass>
            public CustomList(Vector elements)
            {
                super(new <yourClass>Comparator());  //pass comparator to sort
                loadFrom(elements.elements());      
            } 
    
            //Interface implementation
            public String[] getKeywords( Object element )
            {        
                if(element instanceof <yourClass> )
                {            
                    return StringUtilities.stringToWords(element.toString());
                }        
                return null;
            }  
    
            void addElement(Object element)
            {
                doAdd(element);        
            }
    
            //...
        }
    

    You have a full demo available inside the JDE samples folder. It is called keywordfilterdemo.

    To use a custom list like the one you posted, you’ll probably have to code a lot of stuff, like a custom EditField to type in the keywords receiving events on every typed character, linked to a search on a sortered collection (maybe you could use a SortedReadableList for this) which will select in your ListField the first search result returned by this collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a web interface so our helpdesk can create users and setup some of
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
creating 20 viewcontrollers and calling them one after the other from the mainviewcontroller as
Creating simple php login scripts is easy, with simple one table mysql integration. I
Creating a class with variables like this works fine : class Example { public
Creating a mini-database with access, i came across this problem: For the background, i
Creating this ajax styled wordpress portfolio theme and I'm a little stuck on how
When creating an array, such as int[], does this inherit from anything? I thought
Creating Unit Tests in VS2008 (rightclick, create unit tests) causes a lot of references

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.