EditText inside ListView loses and gains focus 3 or 4 times when keyboard shows up. I have properly configured ListView (beforeDescendants) and Activity (adjustPan). I have over 500 items in ListView so I can't use ScrollView. I've made some research and I found that people had same problem. What keeps stealing focus during keyboard show up? Are views invalidated in that process?
Related
I have an Activity which its layout contains a ScrollView with several Fragments and some of the Fragments have RecyclerView which items in it contains EditText inside them.
I set the android:windowSoftInputMode to stateHidden|adjustPan.
It works most of the time well, but on some EditTexts the keyboard hides the text at first, but when starting to type it corrects itself and the screen jumps to the correct position.
UPDATE
I found out that it happens in RecyclerView and not in ListView
so i have some elements (including an EditText) above my ListView. The EditText is essentially a custom search field that I implemented to add some extra functionality to the filtering of the ListView. The EditText cannot be a header of the ListView because I don't want it to scroll off screen as you go through the list.
All works well, except on smaller devices. The screen does not scroll when you are entering text in the EditText so you can't see the live-filtering within the ListView.
Usually you would make the parent item in the layout file a ScrollView and define the activity's windowSoftInputMode as adjustResize, but this is not an option due to the fact that I have this ListView within the layout and it is a sin to have a ListView within the ScrollView.
Ideally, I'm looking for a way to make the following happen:
-upon the EditText gaining focus, I'd like it to scroll to the top of the page, and the listview occupy the rest of the screen.
-upon the EditText losing focus I'd like the screen to return to it's default state.
so far, the only real way that I'm coming up with doing this is to manually detect the keyboard showing up and then hide the top of the screen, and then upon detecting the keyboard disappearing i would show it again.
can anyone suggest something better that isn't such a hack?
I am currently using an ExpandableListView with a EditText as a child item. I want to give focus to the EditText when the item is expanded and automatically display the keyboard.(This turned out to be more difficult than what I expected. I can give focus to the EditText(using this post Focusable EditText inside ListView), but the keyboard is either never shown or it blinks and then hides itself).
Is a ListView the best approach to do this? Should I rather be looking at creating dynamic views inside a LinearLayout of a ScrollView?
Any suggestions/Ideas?
Sounds like some other view other than your TextView is receiving focus after your TextView receives focus. I would debug by overriding onFocus events on some Views and seeing if they get hit after your TextView.
I have a ListView wich contains EditText views. When touching these EditText views, the soft key pad comes up (as desired).
When using android:windowSoftInputMode="adjustPan" the touch pad hides the bottom part of the ListView and thus possibly the EditText view in focus (just touched). I know that this can be solved by using android:windowSoftInputMode="adjustResize">. However, in this case due to resizing the EditText view loses focus.
I am now wondering whether it would be possible to both have the key pad not hide the EditText view and also have it not lose focus.
I have a ScrollView in which I have a quite long form, mainly using EditText elements. The problem is, that when the user scrolls around in this form, ScrollView changes the focus constantly. It seemed to me, that it assigns focus to the first element on screen when the user stops touching the screen, and the fling motion triggers.
How can I disable this?
Just a thought that you can make EditText as non-focusable elements. And when user will click on any item in ListView you can make that particular element focusable again.