I am currently showing softkeyboard using the following code
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput (InputMethodManager.SHOW_FORCED, InputMethodManager.RESULT_HIDDEN);
And Here I d'not bind the softkeyboard with Edittext because of that I had used the above code.
Now I want to close the SoftKeyboard so i am currently using the below code but it is not working.
imm.toggleSoftInput (InputMethodManager.SHOW_FORCED, InputMethodManager.RESULT_HIDDEN);
Can Anyone suggest me what to use for closing the softKeyboard ?
Based on Below Answer I want to let you clear that I am not using EditText, I use Layout on which I want to show Keyboard and Hide keyboard. I want to send keyboard key event to remote area bcoz of that I didnot used editText.
This code hides the keyboard from inside
onItemClick
of anAutoCompleteTextView
You could also try
For hiding keyboard,
Here, “mView” can be any view which is visible on screen
user942821's answer for hiding it works:
But this also works for me to hide it:
You might also want to try:
When using '0' in the first parameter sometimes the keyboard toggles on in the wrong places under weird circumstances that I haven't been able to figure out how to duplicate yet. I'm still testing this last example, but will update when I find out more.
See toggleSoftInput documentation page for more information.
Use this working code :