In the project, the EditText will automatically eject the soft keyboard when the focus is taken, and when you close it, you usually need to press the back key or click the button on the soft keyboard.
Even if the current activity has been completed, the soft keyboard still exists, affecting the user's experience.
Online There are many very detailed methods, such as clicking on other blank areas, the soft keyboard will disappear and the like, we do not require this project, the requirements are as long as
Do not block other operations, and the current activity is closed after the soft keyboard disappears on the line,
Today we share two ways:
This method, if displayed, is hidden if hidden then shows private void Hintkbone () {Inputmethodmanager IMM = (Inputmethodmanager) getactivity (). Getsystemservice (context.input_method_service); Get an instance of Inputmethodmanager if (imm.isactive ()) {//If you turn on Imm.togglesoftinput (Inputmethodmanager.show_implicit, inputmethodmanager.hide_not_always);} }
This method just turns off the soft keyboard private void Hintkbtwo () {Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (context.input_ Method_service); if (Imm.isactive () &&getcurrentfocus ()!=null) {if (Getcurrentfocus (). Getwindowtoken ()!=null) { Imm.hidesoftinputfromwindow (Getcurrentfocus (). Getwindowtoken (), inputmethodmanager.hide_not_always);}}}
Just call the method when you need to click on the event to close the soft keyboard.
Forwarding please indicate address http://blog.csdn.net/jing110fei/article/details/41863821
PS: If someone forwards it,
Android Click to close the soft keyboard