【问题标题】:EditText IME action different on different devicesEditText IME 操作在不同设备上有所不同
【发布时间】:2015-10-05 12:07:42
【问题描述】:

我有一个 EditText,它指定了 IME 操作。

<EditText
    android:id="@+id/passwordEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/prompt_password"
    android:imeActionId="@+id/login"
    android:imeActionLabel="@string/action_sign_in"
    android:imeOptions="actionGo"
    android:inputType="textPassword"
    android:maxLines="1" />

但在 Nexus 5(Android 5.1.1) 上我得到 IME_ACTION_UNSPECIFIED (0) 而在三星 Galaxy(Android 4.2.2) 上我得到 IME_ACTION_GO(2)。

这是因为设备还是安卓版本?我该如何解决这个问题?

【问题讨论】:

    标签: android android-edittext android-softkeyboard ime


    【解决方案1】:

    我不知道为什么,但是如果您尝试设置 imeActionId (2)IME_ACTION_GO,它也适用于 Nexus 5(Android 5.1.1)。我希望这个解决方案对您有所帮助。

    干杯

    <EditText
        android:id="@+id/passwordEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/prompt_password"
        android:imeActionId="2"
        android:imeActionLabel="@string/action_sign_in"
        android:imeOptions="actionGo"
        android:inputType="textPassword"
        android:maxLines="1" />
    

    【讨论】:

    • 你也想查看这些链接:link 1link 2
    • 知道了。 android:imeActionId="2" 是必需的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-30
    • 2021-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多