Setting EditText imeOptions to actionNext has no effect

前端 未结 12 874
终归单人心
终归单人心 2020-12-13 11:46

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 Linear

相关标签:
12条回答
  • 2020-12-13 12:21
    android:inputType="text"
    

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

    0 讨论(0)
  • 2020-12-13 12:26

    below code is force

    android:inputType="text"
    
    0 讨论(0)
  • 2020-12-13 12:28

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

            <EditText 
                android:inputType="text"
                android:maxLines="1"
                android:imeOptions="actionNext" />
    
    0 讨论(0)
  • 2020-12-13 12:29

    These three lines are enough.

    android:singleLine="true"
    android:inputType="text"
    android:imeOptions="actionNext"
    
    0 讨论(0)
  • 2020-12-13 12:33

    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.

    0 讨论(0)
  • 2020-12-13 12:34

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

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

    0 讨论(0)
提交回复
热议问题