【问题标题】:how to get selected item of combo box如何获取组合框的选定项
【发布时间】:2011-07-25 10:18:35
【问题描述】:

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

【问题讨论】:

    标签: java-me combobox lwuit


    【解决方案1】:

    使用此代码:

    combobox.getSelectedIndex(); 
    

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

    combobox.getSelectedItem(); 
    

    返回列表中当前选中的项目,不选中则返回null

    【讨论】:

    • 谢谢巴拉特。请问我可以知道引文吗?因为我很难找到文档
    • @Paniyar:看这里,LWUIT Java documentation.
    【解决方案2】:

    获取您选择的字符串:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      • 2011-10-17
      相关资源
      最近更新 更多