Monday, April 2, 2012

FieldChangeListener for Blackberry AutoCompleteField


Adding FieldChangeListener for Blackberry AutoCompleteField will not work because the Field itself will be using it to display the drop down list.

We have to override the FieldChangeListener. But if we just override FieldChangeListener we will not be able to see the dropdown. So we have to override the method and implement the parent method inside the overridden method. Below is the source code the of the same.

public class MyAutoCompleteField extends AutoCompleteField{
    public MyAutoCompleteField(BasicFilteredList filteredList)           
    {
       super(filteredList);
    }   
     public void fieldChanged(Field field, int context)
     {
         super.fieldChanged(field, context);
         Dialog.alert("text"); // Your code goes here
     }
}

Code above is self explanatory. I have created a custom AutoCompleteField called MyAutoCompleteField and have overridden the fieldChanged method. Usage of this is similar to AutoCompleteField.

No comments:

Post a Comment