I'm showing an input box using AlertDialog
. The EditText
inside the dialog itself is automatically focused when I call AlertDialog.show()
, but the soft keyboard is not automatically shown.
How do I make the soft keyboard automatically show when the dialog is shown? (and there is no physical/hardware keyboard). Similar to how when I press the Search button to invoke the global search, the soft keyboard is automatically shown.
As horkavlna wrote,
toggle
and hide keyboard
methods work. But show variants don't work in my case. So in
onCreate()
I puthideKeyboard(editText);
then inonStart()
I writetoggleKeyboard(editText);
and inonStop()
I writehideKeyboard(editText);
.There are three problems:
1) when an application starts with turned off screen it will hide the keyboard,
2) every time you turn on the screen it will show the keyboard,
3) after application finish you can see the keyboard in Android main screen.
After several tests I removed these methods and in
AndroidManifest
inactivity
tags wroteandroid:windowSoftInputMode="stateVisible"
orandroid:windowSoftInputMode="stateAlwaysHidden"
.or
Well, this is a pretty old post, still there is something to add.
These are 2 simple methods that help me to keep keyboard under control and they work just perfect:
Show keyboard
Hide keyboard
Yes you can do with
setOnFocusChangeListener
it will help you.Try this
try and use: