【问题标题】:how to open numeric keypad automatically? [duplicate]如何自动打开数字小键盘? [复制]
【发布时间】:2012-12-13 19:29:59
【问题描述】:

可能重复:
How to open numeric keyboard when click on EditText?

我有一个 4 EditText 的活动来输入数字。我已经在其布局中将它们的类型更改为数字,但出现了字符软键盘。 Activity 开始时如何显示数字键盘?

有人对此有解决方案吗? 谢谢。

【问题讨论】:

标签: android


【解决方案1】:

你可以在 EditText xml 中添加以下行

android:digits="0123456789"

如果是这样,请删除并在 xml 中添加以下行,它可以正常工作

android:inputType="number" 

检查一次,根据您的问题,这可能是唯一的问题。如果你 inputType = number 那么它永远不会打开字母键盘

【讨论】:

    【解决方案2】:

    试试这个

    EditText editText = (EditText)findViewById(R.id.editText1);
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput((editText), InputMethodManager.SHOW_IMPLICIT);
    

    【讨论】:

      【解决方案3】:

      xml布局文件中只需inputType = "number":

      <EditText
      android:layout_width = "..."
      android:layout_heigth = "..."
      ...
      android:inputType = "number"/>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-01-17
        • 1970-01-01
        • 2019-09-18
        • 2012-12-02
        • 2016-03-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多