我有一个字符串
str = "Hello\tWorld";
当我在J2ME应用程序中打印字符串时,结果是:
"HelloWorld"
代替"Hello<tab space>World"
运行以下示例代码时,文本字段不显示选项卡空间,但只显示没有制表符空间的“HelloWorld”。
示例代码:
public class MyApp extends MIDlet {
private Display display;
private Form frmMain;
public MyApp() {
display = Display.getDisplay(this);
frmMain = new Form("Hello");
}
protected void startApp() throws MIDletStateChangeException {
TextField txt = new TextField("Text", "", 200, TextField.ANY);
txt.setString("Hello\tWorld");
frmMain.append(txt);
display.setCurrent(frmMain);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
destroyApp(unconditional);
notifyDestroyed();
}
}