在Lwuit Mobile应用程序中按键#时如何调用退出命令? [英] How to call Exit Command when I press Key # in Lwuit Mobile Application?

查看:86
本文介绍了在Lwuit Mobile应用程序中按键#时如何调用退出命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Lwuit应用程序中将Exit命令分配给#键吗?当我按#键时,应自动调用Exit命令并退出应用程序.

Can I assign the Exit Command to the # key in an Lwuit Application? When I press the key #, the Exit command should be called automatically and exit the application.

推荐答案

您应该在窗体上侦听带有#的键代码的KeyPress或keyReleased事件,并在按下#键时退出应用程序.

You should listen for a KeyPress or keyReleased event on the form with the keycode for # and exitApplication when the # key is pressed.

protected void keyPressed(int key)
{
    System.out.println("Key Pressed");

    if(key==52) //change 52 to match keyCode for # key 
    {
      Display.getInstance().exitApplication();
    }
}

这篇关于在Lwuit Mobile应用程序中按键#时如何调用退出命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆