Android ListView with EditText loses focus when the keyboard displays

Issue comes when you have ListView with  input capable fields (EditText)  that displays the soft keyboard on focus, the EditText loses its focus for the first time but the second time it works and gains focus.


To Solve this issue you need to add android:descendantFocusability=”beforeDescendants” in your ListView and android:windowSoftInputMode=”adjustPan” for your activity in the app Manifest.

<activity android:name=”com.yourActivity” android:windowSoftInputMode=”adjustPan”/>


and in ListView

<ListView android:id=”@+id/list” android:layout_width=”fill_parent” android:descendantFocusability=”beforeDescendants”
android:layout_height=”fill_parent” android:dividerHeight=”1.0dp”/>


You have to listen for the onFocusChange listener on the EditText and set a variable to keep track. So when the view get rendered again in your getView or getChildView method you can set the focus back to that EditText.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s