1

Okay so I only have one EditText in my layout and one ListView. The ListView is set to have focusable and focusableInTouchMode as false. The same goes for every element inflated in its list (layout of the inflated elements below):

<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="false"
    android:focusableInTouchMode="false">

     <RelativeLayout
         android:id="@+id/relativeLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         android:focusable="false"
         android:focusableInTouchMode="false">
        <Button
            android:text="@string/item_name"
            android:textColor="@color/colorAccent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/itemButton"
            android:background="@drawable/button_selector"
            style="@style/ButtonTheme"
            android:gravity="left|center_vertical"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingBottom="15dp"
            tools:ignore="RtlHardcoded,RtlSymmetry"
            android:focusable="false"
            android:focusableInTouchMode="false" />
        <TextView
            android:text="@string/serial_number"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/serialNumber"
            android:layout_alignParentStart="true"
            android:layout_alignBottom="@id/itemButton"
            android:textSize="12sp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:fontFamily="monospace"
            tools:ignore="RtlHardcoded"
            android:focusable="false"
            android:focusableInTouchMode="false" />
     </RelativeLayout>
    <LinearLayout
        android:orientation="horizontal" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:id="@+id/buttonBar"
        android:layout_alignBottom="@id/relativeLayout"
        android:layout_alignParentStart="true"
        tools:ignore="RtlHardcoded"
        android:focusable="false"
        android:focusableInTouchMode="false">
        <Button
            android:text="@string/delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/deleteButton"
            android:background="#FF0000"
            style="@style/ButtonTheme"
            android:focusable="false"
            android:focusableInTouchMode="false" />
    </LinearLayout></RelativeLayout>

Yet for some reason when I select my EditText it gives me a "Next" button. Clicking this button seems to focus nothing and leaves me with an enter button instead of a "Done" button. If I delete all of the items inside the ListView or never put anything in it in the first place, my EditText will display "Done" as it should.

When looking for what could be taking focus by using View.getNextFocusForwardId(), it gave me and ID of -1. This just makes no sense to me because everything has been explicitly set to be unfocusable.

  • This thread is slightly different but the answer should solve your problem also http://stackoverflow.com/questions/1919742/how-do-i-make-an-android-editview-done-button-and-hide-the-keyboard-when-click – Ben Jul 25 '16 at 23:36
  • @Ben Thank you, setting imeOptions to "actionDone" and maxLines to "1" did the trick. I guess I'll see if anyone can figure out why it's behaving this way. – Nicolas Shupe Jul 26 '16 at 00:29

0 Answers0