How to call Exit Command when I press Key # in Lwuit Mobile Application?

雨燕双飞 提交于 2019-12-02 18:15:37

问题


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.


回答1:


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();
    }
}


来源:https://stackoverflow.com/questions/8834441/how-to-call-exit-command-when-i-press-key-in-lwuit-mobile-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!