How to get the selected item as String in a Blackberry AutoCompleteField?

后端 未结 2 1473
梦毁少年i
梦毁少年i 2021-01-20 03:00

How to get the selected Item as string when using a Blackberry AutoComplete Field. I am able to get the selected index currently. I am Overriding the onSelect method in the

2条回答
  •  青春惊慌失措
    2021-01-20 03:39

    The default implementation of AutoCompleteField#onSelect(Object, int) sets the text of the AutoCompleteField object's AutoCompleteFieldEditField to the select parameter. So you could query for the String that way. Here's a snippet of what I mean:

    AutoCompleteField autoCompleteField = new AutoCompleteField(filterList)
    {
         public void onSelect(Object selection, int type) {
             super.onSelect(selection, type);
             if(selection != null) {
                 String selectionAsString = getEditField().getText();
                 // Do whatever else you need to do with the String.
             }
         }
    };
    

提交回复
热议问题