Frage

I am developing an sms application in Java ME. It has options to select different carriers.

I have implemented an RMS to store the user name, password and the carrier name which is selected from the POPUP ChoiceGroup.

I need to set the ChoiceGroup element to which the user has selected previously from the rms during the next login.

How can I do this if I have the selected Index or String in RMS?

War es hilfreich?

Lösung

I need to set the ChoiceGroup element...

Most straightforward way to do that is to use append method.

    myChoiceGroup.append(string1, null);
    myChoiceGroup.append(string2, null);
    // ... etc

Find details in API documentation, it's pretty easy to read:

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

For more sophisticated uses, there are methods insert and set, API documentation for these is provided at the same link as above.

For the sake of completeness notice above methods are available and have similar semantics not only in POPUP choice group, but in all the objects implementing Choice interface, including other types of ChoiceGroup and List.

Since you also mention working RMS, consider taking a look at RMS tutorials metioned in another answer.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top