I’m new to blackberry development. There is this question I’ve come across several times, which is “How to get the Selected item as string”. The answers that were given did not fully answer the question:
AutoCompleteField autoCompleteField = new AutoCompleteField(filterList)
{
public void onSelect(Object selection, int SELECT_TRACKWHEEL_CLICK) {
ListField _list = getListField();
if (_list.getSelectedIndex() > -1) {
Dialog.alert("You selected: "+_list.getSelectedIndex());
// get text selected by user and do something...
}
}
The point is how can I get the selected text and “do something”. Imagine I want to send the items as a string to a server via post. How would I do that in code?
Thank you! Michael.
These are really (at least) two different things.
To get the selected text, see this answer
To send a HTTP POST request, see this other answer
Normally, it’s also bad to make network requests on the UI thread (which is what will callback your
onSelect()method). So, it would be better to take the HTTP POST code from the second answer, and put it inside therun()method of aRunnableobject you could run on a background thread. Something like this:And use it like this: