简体   繁体   中英

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>

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>

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>

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM