1. Invoke the display system default Input method
Method One,
Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Imm.showsoftinput (M_receiverview (view) that accepts soft keyboard input), inputmethodmanager.show_forced (provides the tag for the current operation, show_forced indicates a force display) );
Method Two,
Inputmethodmanager m= (Inputmethodmanager) Getsystemservice (context.input_method_service);
M.togglesoftinput (0, inputmethodmanager.hide_not_always); (This method can implement the input method to switch the display on the window, if the input method is already displayed on the window, hide, if hidden, display input method to the window)
2. Invoke the hidden system default Input method
((Inputmethodmanager) Getsystemservice (Input_method_service)). Hidesoftinputfromwindow ( WidgetSearchActivity.this.getCurrentFocus (). Getwindowtoken (), inputmethodmanager.hide_not_always); (Widgetsearchactivity is the current activity)
3. Get the status of IME open
Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (context.input_method_service);
Boolean isopen=imm.isactive ();
IsOpen returns True, means the input method opens
1.//Hide Soft keyboard
2,//display soft keyboard, control ID can be Edittext,textview
3, does not automatically eject the keyboard:
With the EditText control, the focus is automatically received the first time it is displayed, and the keyboard pops up, and if you do not want to automatically eject the keyboard, there are two ways:
method One: in the Mainfest file, set the corresponding activity
Android:windowsoftinputmode= "Statehidden" or android:windowsoftinputmode= "stateunchanged".
method Two: can put a hidden textview in the layout, then Requsetfocus when OnCreate.
Note TextView do not set visiable=gone, otherwise it will fail
, you can put a hidden textview in the layout, and then Requsetfocus in the OnCreate.
Note TextView do not set visiable=gone, otherwise it will fail
<textview android:id=" @+id/text_notuse "android:layout_width=" wrap_content "Android:layout_height=" Wrap_content "android:focusable=" true android:focusableintouchmode= "true"/> Text
View TextView = (textView) Findviewbyid (r.id.text_notuse);
Textview.requestfocus ();