Edit Text in ListActivity ListView loses focus when keyboard comes up Edit Text in ListActivity ListView loses focus when keyboard comes up android android

Edit Text in ListActivity ListView loses focus when keyboard comes up


All you really need to do is apply this to your ListView:

XML:

android:descendantFocusability="afterDescendants"

Java:

listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);


For me a combination of the following helped me (especially number 3):

1) Add the following to the related Activity in the manifest file, this is required for your ListView to be resized to fill only the area above the softKeyboard:

android:windowSoftInputMode="adjustResize"

2) With the below the ListView will ONLY get focus only if none of its descendants want it. The descendants (the EditText) needs to get and keep focus.

<ListView...android:descendantFocusability="afterDescendants"/>

3) The automatic showing/hiding of the Spelling Suggestions bar right above the keyboard keeps triggering the ListView to refresh. I turned the Suggestions off for any EditText in my ListView.

<EditText...android:inputType="textNoSuggestions|textVisiblePassword" />


In my case it perfect worked with adding this like of code to manifest:

android:windowSoftInputMode="adjustPan"