我正在用 Java ME 开发一个短信应用程序。它具有选择不同运营商的选项。
我已经实现了一个 RMS 来存储从 POPUP ChoiceGroup 中选择的用户名、密码和运营商名称。
我需要在下次登录期间将用户先前从 rms 选择的 ChoiceGroup 元素设置为。
如果我在 RMS 中选择了索引或字符串,我该如何执行此操作?
最佳答案
I need to set the ChoiceGroup element...
最直接的方法是使用 append
方法。
myChoiceGroup.append(string1, null);
myChoiceGroup.append(string2, null);
// ... etc
在 API documentation 中查找详细信息,它很容易阅读:
public int append(String stringPart,
Image imagePart)
Appends an element to the ChoiceGroup.
Specified by:
append in interface Choice
Parameters:
stringPart - the string part of the element to be added
imagePart - the image part of the element to be added,
or null if there is no image part
Returns:
the assigned index of the element
Throws:
NullPointerException - if stringPart is null
对于更复杂的用途,有方法 insert
和 set
,这些的 API 文档在与上面相同的链接中提供。
为了完整起见,以上方法不仅在 POPUP 选择组中而且在所有实现 Choice
接口(interface)的对象中都可用并且具有相似的语义,包括其他类型的 ChoiceGroup 和 List。
由于您还提到了工作 RMS,请考虑查看 another answer 中提到的 RMS 教程.
关于java - 如何在 Popup ChoiceGroup 中设置元素 - Java ME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11355386/