Precautions for using the mobile phone and keyboard in the Development of j2-based Architecture

Source: Internet
Author: User

Precautions for using the mobile phone and keyboard in the Development of j2-based Architecture

Author: Chen yuefeng

From: http://blog.csdn.net/mailbomb

 

During the development of the program, user input is often required, and all these inputs are carried out through the mobile phone keyboard. The following describes the issues that need to be paid attention to when using the program.

In advanced user interface development, only function keys can be used to control command buttons. These are fixed modes. For example, if two commands are displayed on the mobile phone, the two commands on the screen correspond to each other, the user does not need to process the key value, so there is no porting problem. It is common on all mobile phones.

However, in the development of the low-level user interface, you can directly obtain the key value (keycode) of the mobile phone. Because the key values of different mobile phone buttons are different, there is a porting problem.

On the keyboard of a mobile phone, you can simply divide it into the function key area and the number key area. The function key refers to the left and right soft keys on the mobile phone, the navigation key in the middle, and the answering and hanging keys, the "number key" area refers to the "0-9" and "*" and "#" keys on the keyboard of the mobile phone. Among them, the number of function keys and key values are very different for different mobile phones, while the number of keys in the area of the number key is the same as the key value.

Therefore, in a game, in order to make the program generic, the key value is generally not directly used for judgment, but the game action (gameaction) is used for identification: The implementation code is as follows:

// Convert the keycode into a game action

Int action = getgameaction (keycode );

The relationship between the keycode and the game action is as follows:

Canvas. Up -- number key 2 and up navigation key

Canvas. Down -- numeric keys 8 and down navigation keys

Canvas. Left -- number key 4 and left navigation key

Canvas. Right -- number key 6 and right navigation key

Canvas. Fire -- number key 5 and OK navigation key

Game_a, game_ B, game_c, and game_d correspond to keys 1, 3, 7, 9, 7, 9, *, and # on the keyboard respectively.

After the above conversion, the code implementation is irrelevant to the key value on the mobile phone keyboard.

In addition, for Nokia mobile phones, you can also use Com. nokia. mid. UI. softkey1 and softkey2 in the fullcanvas class are used to control the Left and Right softkeys on Nokia mobile phones, so that the two softkeys can be used for common processing.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.