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

后端 未结 1 1394
滥情空心
滥情空心 2021-01-28 05:36

Can I assign the Exit Command to the # key in an Lwuit Application? When I press the key #, the Exit command should be called aut

1条回答
  •  清酒与你
    2021-01-28 06:21

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

    0 讨论(0)
提交回复
热议问题