BB AutoCompleteField事件不会被处理 [英] BB AutoCompleteField events are not being handled

查看:145
本文介绍了BB AutoCompleteField事件不会被处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经添加到 MainScreen 和类实现 FieldChangeListener 。问题是,当我输入文本和preSS关键而不是当我删除文字,然后preSS的关键处理。下面是我加的:

  ///搜索栏
    BasicFilteredList filterList =新BasicFilteredList();
    串[]术语= {一,B,C,D,E,F,G,H};
    filterList.addDataSet(1,术语,搜索,BasicFilteredList.COMPARISON_IGNORE_CASE);
    autoCompleteField =新AutoCompleteField(filterList){
        公共无效ONSELECT(对象选择,整型){
            如果(类型== || SELECT_ENTER类型== || SELECT_TRACKBALL_CLICK型== SELECT_TRACKWHEEL_CLICK)
                setListView();
        }
   };
// ----------------过缠身方法-----------------
公共无效fieldChanged(场场,诠释上下文){
    如果(场== topBar.getField(0)){
    // 做一点事
    }
    否则如果(字段== topBar.getField(1)){
    // 做一点事
    }
    否则如果(字段== topBar.getField(2)){
    //做一点事
    }
    否则,如果(场== autoCompleteField){
        setListView(); //调试器不会到达这里!
    }
}

修改最终的解决办法是如下简单 -

  autoCompleteField =新AutoCompleteField(filterList){
        公共无效fieldChanged(场场,诠释上下文){
            setListView();
        }
   };


解决方案

至于我明白你的问题,你希望当现场变为空得到通知。如果这是你需要的,你可以点你注意 AutoCompleteField.fieldChanged(场场,诠释方面)什么。这是每当执行的在该领域的文本更改。所以,你可以重写,并检查该文本是一个空字符串,然后解雇你的自定义操作。

顺便说一句,在这种情况下,我认为你不应该把这个:

  autoCompleteField.setChangeListener(本);

由于 AutoCompleteField 工具 FieldChangeListener ,并已在监听本身AutoCompleteField.fieldChanged(场场,诠释上下文)

I've added the to the MainScreen and the class implements FieldChangeListener. The problem is that it handles when I enter text and press the key but not when I delete text and then press the key. Here's how I've added it:

/// search bar
    BasicFilteredList filterList = new BasicFilteredList();
    String[] terms = {"a","b","c","d","e","f","g","h"};
    filterList.addDataSet(1,terms,"search",BasicFilteredList.COMPARISON_IGNORE_CASE);
    autoCompleteField = new AutoCompleteField(filterList){
        public void onSelect(Object selection, int type) {
            if(type == SELECT_ENTER || type == SELECT_TRACKBALL_CLICK || type == SELECT_TRACKWHEEL_CLICK)
                setListView();
        }
   };
//----------------over-ridden method-----------------
public void fieldChanged(Field field, int context) {
    if(field == topBar.getField(0)){
    // do something
    }
    else if(field == topBar.getField(1)){
    // do something
    }
    else if(field == topBar.getField(2)){
    //do something      
    }
    else if(field == autoCompleteField){
        setListView();//debugger never reaches here!
    }
}

EDIT Final solution was as simple as following-

autoCompleteField = new AutoCompleteField(filterList){
        public void fieldChanged(Field field, int context) {
            setListView();
        }
   };

解决方案

As far as I understood your question you would like to get notified when the field becomes empty. If this is what you need you can point your attention to AutoCompleteField.fieldChanged(Field field, int context). It is Executed whenever the text in the field changes. So you could override it and check if the text is an empty string and then fire your custom action.

BTW, in this case I think you should not call this:

autoCompleteField.setChangeListener(this);

because AutoCompleteField implements FieldChangeListener and it already listens for itself in AutoCompleteField.fieldChanged(Field field, int context).

这篇关于BB AutoCompleteField事件不会被处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆