Find String in GWT ListBox

I would like to find the index of the item inside the GWT Listbox by specifying a String value.

For example, if I had a GWT ListBox containing the following elements: "Randy", "Bob" and "Helen", the method I'm looking for for implementation will return 1 if I called it with the "Bob" parameter.

From what I see in the javadoc ListBox, this doesn't seem like a quick way to do this.

Any ideas?

Thanks in advance!

+4
source share
1 answer

My idea of ​​an implementation as a TextBox does not give this out of the box. Keep all the items in the list and in the order you want them to be part of the ListBox.

 List<String> orderedItems=new ArrayList<String> orderedItems.add(0,"Randy"); orderedItems.add(1,"Bob"); orderedItems.add(2,"Helen"); //adding items in the same order as they are in List is the key for(String item:items) { lb.addItem(item); } 

then you can find the index using the List of methods indexOf (..)

+1
source

All Articles