开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜