First, open the Input Method window
1.EditText start activity when the software keyboard XML file is configured in the popup
Manifest the corresponding activity of the configuration, will EditText set the property Android:windowsoftinputmode=statevisible, when entering this page, the default Pop-up IME.
<android:name= ". Ui.login" android:configchanges= "orientation| Keyboardhidden|locale " android:screenorientation=" Portrait " android: Windowsoftinputmode= "Statevisible|adjustpan"></activity >
2. Set the Windowsoftinputmode property in XML to Adjustunspecified|statehidden
3.
- EditText titleinput = (EditText) Findviewbyid (r.id.create_edit_title);
- Titleinput.setfocusable (true);
- Titleinput.requestfocus ();
- Onfocuschange (titleinput.isfocused ());
Whether
Final BooleanIsfocus =Hasfocus;
(NewHandler ()). Postdelayed (NewRunnable () { Public voidrun () { Inputmethodmanager imm=(inputmethodmanager) Titleinput.getcontext (). Getsystemservice (Context.input_method_service); if(isfocus) {imm. Togglesoftinput(0, inputmethodmanager.hide_not_always); } Else{imm. Hidesoftinputfromwindow(Titleinput.getwindowtoken (),0); }
}
Second, hide the Input method window
2. Force Hidden Android IME window
EditText edit= (EditText) Findviewbyid (R.id.edit); Inputmethodmanager imm = (inputmethodmanager) getsystemservice (context.input_method_service); Imm. Hidesoftinputfromwindow (Edit.getwindowtoken (), 0);
2, EditText always does not eject the software keyboard
EditText edit= (EditText) Findviewbyid (R.id.edit); Edit. Setinputtype (Inputtype.type_null);
① in the layout file, place an invisible linearlayout in front of the edittext, allowing him to take the lead in getting the focus:
< LinearLayout android:focusable = "true" Android:focusableintouchmode = "true" Android:layout_width = "0px" Android:layout_height = "0px" />
Properties Android:inputtype : Specifies the type of input method,int type, which can be used to select multiple. The value can be referenced by: Android.text.InputType class. The values include:text,texturi,phone,number, etc.
Acquisition of Focus:
titleinput.setfocusable (true); Titleinput.requestfocus ();
Cancellation of Focus:
Edit.setfocusable (false); or Edit.clearfocus ();
Four: The functions of handling soft keyboards that are often called are as follows:
1. Open the Input Method window:
- Inputmethodmanager Inputmethodmanager = (inputmethodmanager) getsystemservice (Context.input_method_service);
- Edit text or other views that accept soft keyboard input
- Imm.showsoftinput (submitbt,inputmethodmanager.show_forced);
2. Close the Access Law window
- Inputmethodmanager Inputmethodmanager = (inputmethodmanager) getsystemservice (Context.input_method_service);
- Inputmethodmanager.hidesoftinputfromwindow (opelistactivity. This.getcurrentfocus (). Getwindowtoken (),
- Inputmethodmanager.hide_not_always);
- Edit text or other views that accept soft keyboard input
- Inputmethodmanagerwww.2cto.com
- . Showsoftinput (submitbt,inputmethodmanager.show_forced);
3, if the input method is turned off, if not open then open
- Inputmethodmanager m= (Inputmethodmanager) Getsystemservice (Context.input_method_service);
- M.togglesoftinput (0, inputmethodmanager.hide_not_always);
4, 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
Android--edittext Automatic Popup Input Method