Setting EditText imeOptions to actionNext has no effect

AndroidAndroid LayoutFocusIme

Android Problem Overview


I have a fairly complex (not really) xml layout file. One of the views is a LinearLayout (v1) with two children: an EditText(v2) and another LinearLayout(v3). The child LinearLayout in turn has an EditText(v4) and an ImageView(v5).

For EditText v2 I have imeOptions as

android:imeOptions="actionNext"

But when I run the app, the keyboard's return does not check to next and I want it to change to next. How do I fix this problem?

Also, when user clicks next, I want focus to go to EditText v4. I do I do this?

For those who really need to see some code:

<LinearLayout
		android:id="@+id/do_txt_view"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:background="@color/col6"
		android:orientation="vertical"
		android:visibility="gone" >

		<EditText
			android:id="@+id/gm_title"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_margin="5dp"
			android:background="@drawable/coldo_text"
			android:hint="@string/enter_title"
			android:maxLines="1"
			android:imeOptions="actionNext"
			android:padding="5dp"
			android:textColor="pigc7"
			android:textSize="ads2" />

		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="100dp"
			android:orientation="horizontal" >

			<EditText
				android:id="@+id/rev_text"
				android:layout_width="0dp"
				android:layout_height="match_parent"
				android:layout_gravity="center_vertical"
				android:layout_margin="5dp"
				android:layout_weight="1"
				android:background="@drawable/coldo_text"
				android:hint="@string/enter_msg"
				android:maxLines="2"
				android:padding="5dp"
				android:textColor="pigc7"
				android:textSize="ads2" />

			<ImageView
				android:layout_width="wrap_content"
				android:layout_height="match_parent"
				android:layout_gravity="center_vertical"
				android:background="@drawable/colbtn_r”
				android:clickable="true"
				android:onClick=“clickAct”
				android:paddingLeft="5dp"
				android:paddingRight="5dp"
				android:src="@drawable/abcat” />
		</LinearLayout>
	</LinearLayout>

Android Solutions


Solution 1 - Android

Just add android:maxLines="1" & android:inputType="text" to your EditText. It will work!! :)

Solution 2 - Android

singleLine is deprecated. Adding an input type (eg: android:inputType="text") also worked for me.

Use android:maxLines="1" as singleLine is deprecated

Solution 3 - Android

android:singleLine has been deprecated, it is better to combine android:maxLines="1" with android:inputType="text". This would be the code:

<EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:maxLines="1"
        android:inputType="text"
        />

Solution 4 - Android

The answers given here were all very helpful, but I was still struggling to get my keyboard's "Next" to show.

Turns out that when you use Android's android:digits attribute in your XML, it prevents the android:imeOptions="actionNext" from working as expected.

The answer is actually to use the deprecated android:singleLine="True". This seems to force the IME Option to be respected.

Old, Non-Working Code

        <android.support.design.widget.TextInputEditText
            android:id="@+id/first_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- "
            android:ellipsize="end"
            android:hint="@string/first_name"
            android:imeOptions="actionNext"
            android:inputType="textCapWords"
            android:maxLength="35"
            android:maxLines="1" />

Working Code

        <android.support.design.widget.TextInputEditText
            android:id="@+id/first_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- "
            android:ellipsize="end"
            android:hint="@string/first_name"
            android:imeOptions="actionNext"
            android:inputType="textCapWords"
            android:maxLength="35"
            android:maxLines="1"
            android:singleLine="true" />

I'm not a fan of using a deprecated attribute, but for now it seems to get the desired result.

Solution 5 - Android

single line deprecated so you add below code I think inputType must.

        <EditText 
            android:inputType="text"
            android:maxLines="1"
            android:imeOptions="actionNext" />

Solution 6 - Android

Finally i have got sure solution for this issue Just add these 3 lines in your edit text and it will be working fine

        android:maxLines="1"
        android:inputType="text"
        android:imeOptions="actionDone"

Here you can add maxLines according to your requirement. Do not use singleLine as it is deprecated now. Good luck!

Solution 7 - Android

android:inputType="text"

You have to specify an inputType in order for imeOptions to function.

Solution 8 - Android

These three lines are enough.

android:singleLine="true"
android:inputType="text"
android:imeOptions="actionNext"

Solution 9 - Android

Key here is to set input type and imeOptions attributes

<EditText 
   android:inputType="number"
   android:maxLines="1"
   android:imeOptions="actionSearch" />

Solution 10 - Android

Only this worked for me.

Change it:

android:maxLines="1"
android:inputType="text"
android:imeOptions="actionNext"

on that:

android:singleLine="true"
android:inputType="text"
android:imeOptions="actionNext"

Solution 11 - Android

below code is force

android:inputType="text"

Solution 12 - Android

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/auth_register_re_password"
    android:hint="Enter Password Again"
    android:imeActionLabel="login"
    android:gravity="center"
    android:imeOptions="actionUnspecified"
    android:inputType="textPassword"
    android:maxLines="1"/>

Solution 13 - Android

Only put in your EditText xml

android:inputType="text"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKatedral PillonView Question on Stackoverflow
Solution 1 - AndroidSurendra KumarView Answer on Stackoverflow
Solution 2 - AndroidpratnalaView Answer on Stackoverflow
Solution 3 - AndroidvoghDevView Answer on Stackoverflow
Solution 4 - Androidwelshk91View Answer on Stackoverflow
Solution 5 - AndroidManiView Answer on Stackoverflow
Solution 6 - AndroidAli NawazView Answer on Stackoverflow
Solution 7 - Androidpaulb444View Answer on Stackoverflow
Solution 8 - AndroidGooglianView Answer on Stackoverflow
Solution 9 - Androidpavan bangalalaView Answer on Stackoverflow
Solution 10 - AndroidZakhar RodionovView Answer on Stackoverflow
Solution 11 - AndroidMehrdadView Answer on Stackoverflow
Solution 12 - Androidsaigopi.meView Answer on Stackoverflow
Solution 13 - AndroidLiongView Answer on Stackoverflow