【发布时间】:2011-07-25 10:18:35
【问题描述】:
我正在将 lwuit 与 j2me 一起使用。如何获取组合框选定项或索引?我找到了setSelectedIndex 的函数,但没有找到被选中的函数。
【问题讨论】:
我正在将 lwuit 与 j2me 一起使用。如何获取组合框选定项或索引?我找到了setSelectedIndex 的函数,但没有找到被选中的函数。
【问题讨论】:
使用此代码:
combobox.getSelectedIndex();
返回列表中当前选定的偏移量。
combobox.getSelectedItem();
返回列表中当前选中的项目,不选中则返回null
【讨论】:
获取您选择的字符串:
String selected_text = ComboBox.getItemAt(ComboBox.getSelectedIndex());
【讨论】: