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
- @ Override
- Protected void onresume (){
- // Todo auto-generated method stub
- Super. onresume ();
- Inputmethodmanager im = (inputmethodmanager) getsystemservice (input_method_service ));
- Im. showsoftinput (TV, 0 );
- }
- }
Case 2:
Java code
- TV. setonclicklistener (New onclicklistener (){
- @ Override
- Public void onclick (view arg0 ){
- // Todo auto-generated method stub
- Inputmethodmanager im = (inputmethodmanager) getsystemservice (input_method_service ));
- If (IM. showsoftinput (TV, inputmethodmanager. show_forced )){
- System. Out. println ("return is true fullscreenmode"
- + IM. isfullscreenmode ());
- } Else {
- System. Out. println ("return is not true ");
- }}});
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.