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

Reply
Contributor
Posts: 12
Registered: ‎10-12-2010
My Device: Not Specified

ListFieldCallback seems to break KeywordFilterField

I am attempting to create a search screen based on a KeywordFilterField.  I want to add  ListFieldCallback to format the list entries since many are longer than one line.  I have added a ListFieldCallback and the records display fine, but it seems to break the KeywordFilterField in that when search text is entered, the list does not filter (i.e. all records continue to be displayed).  If I remove the ListFieldCallback the KeywordFilterField searches as I expect, but the display of the records is lousy.

Does anyone know why ListFieldCallbacks change the behavior of the KeywordFilterField?

Here are the lines of code that I believe are relevant.  I am not convinced that these are the problem however.

In my constructor for my screen:
    _keywordFilterField.setCallback(listFieldCallback);
    _keywordFilterField.setRowHeight(rowHeight);
        
My ListFieldCallback implementation:
    private ListFieldCallback listFieldCallback = new ListFieldCallback() {

        public int indexOfList(ListField listField, String prefix, int start) {
            return -1; // Not implemented.
        }

        public int getPreferredWidth(ListField listField) {
            // Use all the width of the current LCD.
            return Display.getWidth();
        }

        public Object get(ListField listField, int index) {
            if ( listField == _keywordFilterField ) {
                // If index is out of bounds an exception will be thrown (desired
                // behavior).
                return _tocEntries.elementAt(index);
            }
            return null;

        }

        public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) {
            int indent = 0;
            TOCEntry entry = (TOCEntry) _tocEntries.elementAt(index);
            ListRecordUtil.drawListRecord(SearchScreen.this, graphics, y, width, indent, entry);
        }
    };

Dave

Contributor
Posts: 12
Registered: ‎10-12-2010
My Device: Not Specified

Re: ListFieldCallback seems to break KeywordFilterField

I found a solution to this  here.