GWT listbox - how to look up item index using text?
Is there anyway to look up an item's index number using the item text in GWT listbo开发者_开发技巧x?
Nope, you have to iretare thru them and find that index yourself.
Like this:
String text = "listBoxText";
int indexToFind = -1;
for (int i=0; i<listBox.getItemCount(); i++) {
if (listBox.getItemText(i).equals(text)) {
indexToFind = i;
break;
}
}
精彩评论