从Blackberry中的KeywordFilterField中删除默认的ListField

时间:2012-08-29 07:11:19

标签: search blackberry custom-lists blackberry-editfield

我是Black berry开发的初学者,关于如何更多地自定义搜索结果而不是使用到我的文本框中。

我想在Blackberry应用程序中实现动态搜索功能,用户在文本字段中输入字符,匹配的内容将显示在列表的下方。

现在我已经实现了它,但我想要的只是文本字段应该显示而不是KeywordFilterField附带的内置列表字段。

当文本更改时,自定义列表将自动填充,因为我已在Fieldchanged()事件中编码,但还显示了我不想要的内置列表。enter image description here]![enter image description here

正如您在图像中看到的,我想要文本字段,我不想要默认列表字段,我想要CustomListField(正常工作没有问题)。

1 个答案:

答案 0 :(得分:1)

得到解决方案或我们可以说的技巧。

首先,我们必须在应用笔记中实现KeywordFilterField,我们不得将其添加到我们的屏幕中,我们将使用KeywordFilterfield的功能。

现在我们需要在fieldChanged()事件中将TextField添加到屏幕中,只需为KeywordFilterField设置关键字。如下。

   public void fieldChanged(Field field, int context) {
        // TODO Auto-generated method stub

        SearchTextBox temp=(SearchTextBox)field;
        _keywordFilterField.setKeyword(temp.getText());
    }

现在,一旦我们设置了关键字,KeywordFilterField的更改侦听器就会被触发,那么我们可以编写代码来显示自定义列表字段,如下所示

_keywordFilterField.setChangeListener(new FieldChangeListener(){

    public void fieldChanged(Field field, int context) {

        KeywordFilterField k=(KeywordFilterField)field;

        //Use k.getResultList(); method to fetch the resulting elements.

        //Write the code here for custom list to display.   
        }

});