我已經添加到MainScreen
和類實現FieldChangeListener
。問題在於,當我輸入文本並按下按鍵時,它會處理,但當我刪除文本時,按下該按鍵則不會。下面是我添加了它:BB AutoCompleteField事件沒有被處理
/// 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!
}
}
編輯最終的解決方案是爲以下各項
autoCompleteField = new AutoCompleteField(filterList){
public void fieldChanged(Field field, int context) {
setListView();
}
};
我想你忘了添加autoCompleteField.setChangeListener(this); –
nope ...而是我刪除它,因爲@Arhimed指出,「AutoCompleteField」已經聽取了它自己。 – tipycalFlow