1. Call the display system default Input method
Method One,
Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Imm.showsoftinput (M_receiverview (view) with soft keyboard input, inputmethodmanager.show_forced (provides markup for the current action, show_forced indicates 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, then hide, if hidden, then display the input method to the window)
2. Call 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 Input Method open state
Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Boolean isopen=imm.isactive ();
IsOpen returns true to indicate that the input method is open
1.//Hide Soft keyboard
((Inputmethodmanager) Getsystemservice (Input_method_service)). Hidesoftinputfromwindow ( WidgetSearchActivity.this.getCurrentFocus (). Getwindowtoken (), inputmethodmanager.hide_not_always);
2,//display soft keyboard, control ID can be Edittext,textview
((Inputmethodmanager) Getsystemservice (Input_method_service)). Showsoftinput (Control ID, 0);
3, does not automatically eject the keyboard:
With the EditText control, the first display will automatically get focus, and pop up the keyboard, if you do not want to automatically eject the keyboard, there are two ways:
Method One: In the Mainfest file, the corresponding activity settings
Android:windowsoftinputmode= "Statehidden" or android:windowsoftinputmode= "stateunchanged".
Method Two: 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
, 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
1 <TextView2 android:id= "@+id/text_notuse"3 android:layout_width = "Wrap_content"4 android:layout_height= "Wrap_content"5 android:focusable= "true" 6 android:focusableintouchmode= "true" />78 TextView TextView = (TextView) Findviewbyid (r.id.text_notuse); 9 textview.requestfocus ();
How Android calls Show and hide system default Input method (one)