StringItem
is an item that can contain static text, hyperlinks and buttons.
A StringItem
is always non-editable, although both the
label and the textual content of a StringItem
may be
modified by the application. The font of the label text can not be set.
The intended behavior is defined by setting the appearance mode to be
one of the following: PLAIN
, HYPERLINK
,
or BUTTON
.
If the StringItem
contains a long text, the text
forms a paragraph that wraps on the screen. Text wrapping in a paragraph is
based on word boundaries. A newline character embedded in StringItem
text
creates a new line. If the appearance mode set is BUTTON
only
one line of text is possible. In BUTTON
mode an embedded
newline character truncates the text, and an ellipsis character is shown.
Source code for the example:
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ExampleForm5 extends MIDlet { private Display display; private Form form; public ExampleForm5() { form = new Form("Form example 5"); // StringItem(label, text); StringItem sItem = new StringItem("Text Example", "Hello World!"); form.append(sItem); exit = new Command("Exit", Command.EXIT, 1); form.addCommand(exit); form.setCommandListener(this); } public void startApp() { display = Display.getDisplay(this); display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(false); notifyDestroyed(); } } }
For more information about S60-specific StringItem
features,
see StringItem implementation
notes.