0

In my Android application, I have ListView, with header contains 2 editText. When I try to focus on lower editText, the keyboard shows up, and changes focus to upper editText. Header layout xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/name"
        android:hint="Title"
        android:layout_alignParentTop="true"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:nextFocusUp="@id/name"
        android:inputType="text"
        android:hint="Wordpack description"
        android:id="@+id/description"
        android:layout_below="@+id/name" />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/description"
        android:inputType="text"
        android:id="@+id/locale"
        android:text="Select language"/>
</RelativeLayout>

enter image description here

Feelfree
  • 80
  • 3
  • 15

1 Answers1

1

Seems like ListView is taking focus and giving it to the first child when you tap on it. Check out this answer. From the gist of it, you need to add the following in your activity on the manifest:

android:windowSoftInputMode="adjustPan"

And add this to your ListView:

android:descendantFocusability="beforeDescendants"
Community
  • 1
  • 1
Pablo Baxter
  • 2,144
  • 1
  • 17
  • 36
  • This might be a secondary solution: http://stackoverflow.com/questions/6918494/edit-text-in-listactivity-listview-loses-focus-when-keyboard-comes-up/15294709#15294709 – Pablo Baxter May 12 '17 at 19:50
  • With second solution the problem still occur, but `android:windowSoftInputMode="adjustPan` made the work. Thanks you soo much! – Feelfree May 12 '17 at 20:10