Android: how to close explicitly displayed soft keyboard?

First, don't use toggleSoftInput(). That does what it name says -- toggles the state of the IME. If you actually want it make sure it is shown, use showSoftInputFromWindow() Second, there is no reason to call restartInput() Calling showSoftInput() with a 0 flag is exactly what the framework does when you tap on a text view to show the IME.In fact here is the code: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/widget/TextView.java;h=97b05af0aae2db952342dd3defe428506f76abd4;hb=HEAD#l6906 If you can get the IME to be shown by tapping on the text view, but your own call is not working, you really need to figure out why your call is not working.

I would strongly recommend NOT using SHOW_FORCED -- that has somewhat special behavior, which I doubt you want. (For example if the user presses home the IME will stay open. Generally not desirable.

) The most likely reason for your call to hide the IME to not work is that your window doesn't have input focus at that point... you will probably see a message in the log if this is the case. In fact, be sure to look in the log anyway since often messages are printed when problems happen.

First, don't use toggleSoftInput(). That does what it name says -- toggles the state of the IME. If you actually want it make sure it is shown, use showSoftInputFromWindow().

Second, there is no reason to call restartInput(). Calling showSoftInput() with a 0 flag is exactly what the framework does when you tap on a text view to show the IME. In fact here is the code: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/widget/TextView.java;h=97b05af0aae2db952342dd3defe428506f76abd4;hb=HEAD#l6906 If you can get the IME to be shown by tapping on the text view, but your own call is not working, you really need to figure out why your call is not working.

I would strongly recommend NOT using SHOW_FORCED -- that has somewhat special behavior, which I doubt you want. (For example if the user presses home the IME will stay open. Generally not desirable.) The most likely reason for your call to hide the IME to not work is that your window doesn't have input focus at that point... you will probably see a message in the log if this is the case.

In fact, be sure to look in the log anyway since often messages are printed when problems happen.

Thank you. I switched to showSoftInput(), but the keyboard was still not showing. I assumed this was because the show call was in my dialog constructor which was possibly followed by some sort of layout command which was re-hiding keyboard.

Moving the call to mEditText. Post(...) fixed this. – ab11 Mar 17 at 16:13.

First, don't use toggleSoftInput(). That does what it name says -- toggles the state of the IME. If you actually want it make sure it is shown, use showSoftInputFromWindow().

Second, there is no reason to call restartInput(). Calling showSoftInput() with a 0 flag is exactly what the framework does when you tap on a text view to show the IME. If you can get the IME to be shown by tapping on the text view, but your own call is not working, you really need to figure out why your call is not working.

I would strongly recommend NOT using SHOW_FORCED -- that has somewhat special behavior, which I doubt you want.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions