Problems with the android softkeypad keypad and events related to the Enter key in the Custom keypad

Source: Internet
Author: User

Android softkeypad
1. By default, the eidtext control is displayed automatically after you click it to obtain the focus, provided that you are in the portrait screen. However, when the horizontal disk is used, the soft keyboard will not pop up automatically.
The keyboard is opened by default when the simulator is landscape screen, so even if you use code to display the soft keyboard, it cannot be displayed, but like a real mobile phone (with a physical keyboard (hardware disk) such as G1) it's different. You can use the sensor to screen the screen without opening the keyboard. You can use the code to display the soft keyboard.

2. When using code to display and hide the soft keyboard, you can write it in The onclick event of a control or use timer to control it. If you do not directly use oncreate or onresume, the reason I got from the Internet is that the software disk can only be displayed after all views are painted. First case:

Java code
  1. @ Override
  2. Protected void onresume (){
  3. // Todo auto-generated method stub
  4. Super. onresume ();
  5. Inputmethodmanager im = (inputmethodmanager) getsystemservice (input_method_service ));
  6. Im. showsoftinput (TV, 0 );
  7. }
  8. }

Case 2:

Java code
  1. TV. setonclicklistener (New onclicklistener (){
  2. @ Override
  3. Public void onclick (view arg0 ){
  4. // Todo auto-generated method stub
  5. Inputmethodmanager im = (inputmethodmanager) getsystemservice (input_method_service ));
  6. If (IM. showsoftinput (TV, inputmethodmanager. show_forced )){
  7. System. Out. println ("return is true fullscreenmode"
  8. + IM. isfullscreenmode ());
  9. } Else {
  10. System. Out. println ("return is not true ");
  11. }}});

Enter key and related events in the Custom keypad

After the SDK is upgraded to 1.5, when the text input box (edittext and its subclass) gets the focus, the system's built-in Soft Keyboard will pop up.

In order to implement some custom functions, I have studied a little bit

* When layout has multiple edittexts and the Android: singleline attribute of each control is set to true, the text on the Enter key of the Soft Keyboard will change to "Next ", press next edittext to automatically obtain the focus (implementing the "Next" function). When the last control gets the focus, the text on the Enter key will become "done ", the keyboard is automatically hidden after you press it.

* Set the ime options attribute of edittext to different values. Different texts or patterns can be displayed on the Enter key.
Actionnone: Enter key. Press the button and move the cursor to the next line.
Actiongo: Go,
Actionsearch: a magnifier
Actionsend: Send
Actionnext: Next
Actiondone: done to hide the keyboard, even if it is not the last text input box
(There are other values that can be set, but you are too lazy to read them :-))

* Set the onkeylistener of the text box. When the keycode is 66, it indicates that the Enter key is pressed and you can write the desired action.

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.