开发者

GWT listbox - how to look up item index using text?

开发者 https://www.devze.com 2023-03-27 01:34 出处:网络
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.

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;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消