Comment appeler commande Quitter lorsque j'appuie sur la touche # dans LWUIT Application mobile?

StackOverflow https://stackoverflow.com/questions/8834441

Question

Puis-je attribuer le commandement de Exit à # clé dans une LWUIT application? Lorsque j'appuie sur la touche # , la commande Exit doit être appelé automatiquement et quitter l'application.

Était-ce utile?

La solution

Vous devriez écouter un événement KeyPress ou keyReleased sur le formulaire avec le code d'activation pour # et exitApplication lorsque la touche # est pressée.

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

    if(key==52) //change 52 to match keyCode for # key 
    {
      Display.getInstance().exitApplication();
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top