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.
When the list is long enough to cover the soft keyboard, the
EditText
inListview
loses focus when pressed on Android 4.x.One solution is to wrap the
Listview
in a linear layout with a height of half the screen.Whenever the
Listview
doesn't cover the softkeyboard, everything is fine.In my case I've added local value currentlyFocusedRow in my Adapter. In the method getView() I've add these code to each editText:
I was having problems with the ActionBar "stealing" focus when I pressed on an EditText located within a ListView row. The above solutions did not work, but the following solution worked for me:
http://www.mysamplecode.com/2013/02/android-edittext-listview-loses-focus.html
Basically I added this to my ListView:
and added this to my activity: