I want to automatically show the soft-keyboard when an EditText
is focused (if the device does not have a physical keyboard) and I have two problems:
When my
Activity
is displayed, myEditText
is focused but the keyboard is not displayed, I need to click again on it to show the keyboard (it should be displayed when myActivity
is displayed).And when I click done on the keyboard, the keyboard is dissmissed but the
EditText
stays focused and y don't want (because my edit is done).
To resume, my problem is to have something more like on the iPhone: which keep the keyboard sync with my EditText
state (focused / not focused) and of course does not present a soft-keyboard if there is a physical one.
android:windowSoftInputMode="stateAlwaysVisible"
-> in manifest File.edittext.requestFocus();
-> in code.This will open soft keyboard on which edit-text has request focus as activity appears.
You can also create a custom extension of the EditText that knows to open the soft keyboard when it receives focus. That's what I've ended up doing. Here's what worked for me:
I have had some recent luck in some simple cases with the code below. I haven't finished all testing but....
And presto the keyboard shows up.
I had a similar problem using view animations. So I've put an animation listener to make sure I'd wait for the animation to end before trying to request a keyboard access on the shown edittext.