java - 如何在 Popup ChoiceGroup 中设置元素 - Java ME

标签 java java-me midp lcdui rms

我正在用 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

对于更复杂的用途,有方法 insertset,这些的 API 文档在与上面相同的链接中提供。

为了完整起见,以上方法不仅在 POPUP 选择组中而且在所有实现 Choice 接口(interface)的对象中都可用并且具有相似的语义,包括其他类型的 ChoiceGroup 和 List。

p>

由于您还提到了工作 RMS,请考虑查看 another answer 中提到的 RMS 教程.

关于java - 如何在 Popup ChoiceGroup 中设置元素 - Java ME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11355386/

相关文章:

java - Postman 中的 GET 请求发送 header 中的值,但未到达 Java 中的 REST 方法

java - 有没有办法在手机上查找java内存状态?

java - J2ME图像旋转

java - J2ME中如何生成哈希值?

java - 为什么这个java函数不指示文件路径无效

java - 将音乐添加到我的音板项目

Java Micro Edition (J2ME) - 使用记录存储枚举更新记录

java-me - j2me在 Canvas 之间切换时屏幕闪烁

java - 远程调用的事务管理

黑莓多操作系统版本兼容性问题