I know there are a lot of similar questions out here but I couldn't get any of the provided solutions working in a simple sample app.
The problem occurs when the softkeyboard is shown for the first time. As soon as it is shown, only by pressing the editText again makes it editable.
Tried the following:
android:windowSoftInputMode="adjustPan|adjustResize"
This is not solving any issues. It seems that this line is mandatory to have the activity resized after the softkeyboard is popping up. Unfortunately, it's also causing any EditTexts to lose focus. This is probably to the ListView itself gaining focus after the resizing process. So I tried the following workaround:
listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
This always causes the first visible EditText that the ListView
contains to gain focus, which is undesirable. The second EditText in the second row should instead gain focus when pressed, which is not happening. Also, if I eventually managed to focus another EditText other then the first one shown (e.g. by pressing 'Next' on the softkeyboard
), the first visible one will receive focus after the keyboard is dismissed and the ListView being resized to its full size again.
I tried several other things like intercepting onFocusChange()
events for the ListView, while knowing which EditText was pressed by its TouchListener
. Requesting the focus for that certain EditText again did not lead to any success either.
Using a ScrollView
instead of a ListView
as suggested by other users is not an option either for the concerned project.
EditText
should be pressed one more time, in order to be operational, but the fact that the softkeyboard appears, because it is triggered by a field, which is editable and gains focus at first. You can try thispublic void hideSoftKeyboard(View v) { Activity activity = (Activity) v.getContext(); InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }
. – Carnaticsoftkeyboard
to appear at first and I guess that theEditText
would have to just be pressed in order to trigger the editing in it. – CarnaticEditText
gains focus the first time the keyboard appears? What I mean is - where is theRequestFocus
situated? – Carnatic