【问题标题】:Numeric Keypad ANdroid changes to alphanumeric keypad数字键盘 AAndroid 更改为字母数字键盘
【发布时间】:2017-08-25 08:08:42
【问题描述】:

我有一个输入类型=数字的 textinputedittext。如果用户单击 textinputedittext 以外的任何地方,我使用以下函数来关闭键盘 -

public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager =
            (InputMethodManager) activity.getSystemService(
                    Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(
            activity.getCurrentFocus().getWindowToken(), 0);
}

但不是键盘关闭,而是简单地转换为字母数字(默认)键盘,然后当第二次单击时键盘关闭。 我无法理解为什么键盘而不是关闭转换为字母数字。

【问题讨论】:

  • 此问题已回答here(可能重复)
  • 感谢@Dondani,虽然不重复,但我得到了解决方案
  • 问题是由于 xml 属性 focusableintouch mode ,因此视图被聚焦,导致键盘出现问题。

标签: android android-keypad android-textinputedittext


【解决方案1】:
android:focusableInTouchMode="false"

在屏幕的父布局上添加这个属性解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-02
    • 2018-07-27
    • 2019-05-26
    • 2014-04-29
    • 2020-07-06
    • 1970-01-01
    相关资源
    最近更新 更多