我在 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 个
最佳答案
关于java - j2me+在form中以递减形式打印数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6595875/