本文介绍了如何通过按键关闭J2ME应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中有一个带有Nokia SDK插件的J2ME项目,在其中使用了Canvas外观.用户将按一个键退出该应用程序.
但是我真的不知道按键事件后关闭的方式.

I have a J2ME project in Eclipse with Nokia SDK plugin, in which I use a Canvas skin. The users will press a key to quit the application.
But I don''t really know the way to close after key pressing event.
Help me, please!

推荐答案

MyCanvas theCanvas = new MyCanvas(this, ...);


在Canvas构造函数中,保存Midlet参考:


in the Canvas constructor, save the Midlet reference:

class MyCanvas extends Canvas implements CommandListener {
  MyMidlet theMidlet;

  public MyCanvas(MyMidlet m, ...) {
    this.theMidlet = m;
    ...
  }

...
}


然后,当您要从MyCanvas中的keyPressed关闭Midlet时,
只需致电theMidlet.destroyApp()

彼得


Then, when you want to close the midlet from keyPressed in MyCanvas,
just call theMidlet.destroyApp()

Peter




这篇关于如何通过按键关闭J2ME应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:11