简体   繁体   中英

J2ME: How to press keypad programmatically?

Is it possible to press keypad programmatically so that number for the key pressed shows on the screen? See the screenshot below for more explanation please:

替代文字

Details:
Nokia N70
CLDC 1.1
MIDP 2.0

How you approach it will depend on what you want to achieve.

You can quite easily simulate pressing keys on a Canvas , by calling your Canvas's keyPressed() , keyReleased() and keyRepeated() methods directly.

This could be good for testing a canvas-based game, ensuring a given state is entered when certain keys are pressed on the canvas.

However, this won't allow you to control any form-based interaction, or native prompts. So you can't start the MIDlet, navigate through a LCDUI Form or List , accept a native security prompt, or edit a native TextBox . You'd need to use an emulator and some form of test scripting framework which simulates keypresses, such as Eggplant .

if you want to mimicking the keypressed process, just call the keypressed with the int of key as argument, for example keyPressed(-8);

Or are you trying to display the key number in the screen ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM