rajat44
rajat44

Reputation: 5131

imeOption="actionNext" not working in TextInputLayout

I am using floating hint from material design. I want to shift focus from one EditText to the next, So I have put imeOptions="actionNext" in all editTexts and imeOptions="actionDone in the last EditText. But focus is not shifting to next EditText.

Below is the snippet of my xml.

<android.support.design.widget.TextInputLayout
    android:id="@+id/streetWrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/TextInputStyle">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Street/Locality *"
        android:imeOptions="actionNext"
        android:maxLines="1"/>

</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
    android:id="@+id/flatWrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/_10sdp"
    android:theme="@style/TextInputStyle">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Building Name / Flat Number*"
        android:imeOptions="actionNext"
        android:maxLines="1"/>

</android.support.design.widget.TextInputLayout>

Upvotes: 13

Views: 8062

Answers (4)

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

You should add android:imeOptions="actionNext" in EditText section.

<android.support.design.widget.TextInputLayout
    android:id="@+id/streetWrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/TextInputStyle">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:imeOptions="actionNext"
        android:maxLines="1"
        android:inputType="text"/>
</android.support.design.widget.TextInputLayout>

Upvotes: 21

Primož Ivančič
Primož Ivančič

Reputation: 2376

In my case I had to also add android:nextFocusForward="@id/secondInput". Make sure you are adding id's on TextInputEditText and not on TextInputLayout.

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="First input">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/firstInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:imeOptions="actionNext"
        android:inputType="number"
        android:nextFocusForward="@id/secondInput">

        <requestFocus />
    </com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Second input">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/secondInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:imeOptions="actionDone"
        android:inputType="text"
        android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>

Upvotes: 1

You should add android:inputType="text" on section Tag

If you not adding inputType imeOption is not work

Try this :

<android.support.design.widget.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/dimens_16dp">

                    <android.support.design.widget.TextInputEditText
                        android:id="@+id/et_impian"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/text_fill_your_dream_here"
                        android:imeOptions="actionNext"
                        android:inputType="text"
                        android:backgroundTint="@color/color_green_manulife"/>

                </android.support.design.widget.TextInputLayout>

Upvotes: 3

Ferdous Ahamed
Ferdous Ahamed

Reputation: 21766

Add attribute android:inputType="text" to your EditText.

Try this:

<android.support.design.widget.TextInputLayout
    android:id="@+id/streetWrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Street/Locality *"
        android:imeOptions="actionNext"
        android:maxLines="1"
        android:inputType="text"/>

</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
    android:id="@+id/flatWrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/_10sdp">

    <EditText

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Building Name / Flat Number*"
        android:imeOptions="actionNext"
        android:maxLines="1"
        android:inputType="text"/>

</android.support.design.widget.TextInputLayout>

Upvotes: 7

Related Questions