我在j2me工作。请帮助我。 我使用了以下代码: -
protected void startApp() {
display = Display.getDisplay(this);
form = new Form("Item Layout");
TxtData=new TextField("Number","" , 4, TextField.NUMERIC);
GO = new Command("Go", Command.OK, 1);
Exit = new Command("Exit", Command.EXIT, 2);
form.append(TxtData);
form.addCommand(GO);
form.addCommand(Exit);
form.setCommandListener(this);
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void commandAction(Command cmnd, Displayable dsplbl) {
String label = cmnd.getLabel();
if(label.equals("Go")){
number=Integer.parseInt(TxtData.getString());
timer = new Timer();
task = new TestTimerTask();
timer.schedule(task,500,500);
} else if(label.equals("Exit")){
destroyApp(true);
}
}
private class TestTimerTask extends TimerTask{
public final void run(){
number--;
form.append(""+ number+"\n");
if(number==0){
timer.cancel();
}
}
}
我的输出位于: -
但我想以这种方式: -
而不是串联打印数字..想要打印唯一的单个递减数字。
在屏幕上只有6个 那么屏幕上只有5个