我有一个字符串
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();
}
}