如何获取组合框的选定项

发布于 2024-11-25 17:58:43 字数 198 浏览 0 评论 0原文

我正在将 lwuit 与 j2me 一起使用。如何获取组合框选定的项目或索引?我找到了 setSelectedIndex 的函数,但是不是为了被选中。

i'm using lwuit with j2me . how to get combo box selected item or index? i found the function for setSelectedIndex but not for getting the selected.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海夜未眠 2024-12-02 17:58:43

使用此代码:

comboBox.getSelectionModel().getSelectedIndex(); 

返回列表中当前选定的偏移量。

comboBox.getSelectionModel().getSelectedItem(); 

返回列表中当前选定的项目或 null 表示没有选择

Use this code :

comboBox.getSelectionModel().getSelectedIndex(); 

To return the current selected offset in the list.

comboBox.getSelectionModel().getSelectedItem(); 

To return the current selected item in the list or null for no selection

挽容 2024-12-02 17:58:43

要获取您选择的字符串:

String selected_text = ComboBox.getItemAt(ComboBox.getSelectedIndex());

To get what you selected as a string:

String selected_text = ComboBox.getItemAt(ComboBox.getSelectedIndex());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文