将 EditText meOptions 设置为 actionNext 没有效果

我有一个相当复杂的 xml 布局文件。其中一个视图是 LinearLayout (v1) ,它有两个子级: EditText (v2)和另一个 LinearLayout (v3)。子 LinearLayout 依次具有 EditText (v4)和 ImageView (v5)。

对于 EditText v2,我将 imOptions 设置为

android:imeOptions="actionNext"

但是当我运行应用程序,键盘的 return不检查到 next,我希望它改为 next。我该如何解决这个问题?

另外,当用户单击下一步时,我希望焦点转到 EditText v4?

对于那些真正需要看到一些代码的人:

<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>
55809 次浏览

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

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"
/>

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

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

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

        <EditText
android:inputType="text"
android:maxLines="1"
android:imeOptions="actionNext" />
<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"/>

Key here is to set input type and imeOptions attributes

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

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

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!

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.

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"

below code is force

android:inputType="text"

These three lines are enough.

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

Only put in your EditText xml

android:inputType="text"

Add this following lines to in your EditText.

<Edittext
android:layout_height = "match_parent"
android:layout_widht = "match_parent"
android:inputType="text"
android:maxLines="1"
android:imeOptions="actionSearch"
android:imeActionLabel="Search"
android:hint = "Search Here" />