简体   繁体   English

单击 EditText 时如何打开数字键盘?

[英]How to open numeric keyboard when click on EditText?

I read several other posts and using input.setInputType(TYPE_NUMBER_FLAG_DECIMAL);我阅读了其他几篇文章并使用 input.setInputType(TYPE_NUMBER_FLAG_DECIMAL); does open the keyboard but its not the numeric keyboard确实打开了键盘,但不是数字键盘

android:inputType="number" 添加到您的 xml 中的编辑文本,当您在编辑文本内部单击时,它将自动打开数字键盘。

Add android:inputType="number" in xml will automatically open numeric keyboard when click on EditText, but this will allow you to enter characters only numbers, and if you wanna enter other characters, you may try this:在 xml 中添加android:inputType="number"将在单击 EditText 时自动打开数字键盘,但这将允许您仅输入字符数字,如果您想输入其他字符,您可以试试这个:

android:inputType="number"
android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

Add this line in your edittext xml, clean build and run it.在您的edittext xml 中添加这一行,清理构建并运行它。 It should works.它应该有效。

android:inputType="number"

You can add the following to your EditText block in XML file:您可以将以下内容添加到 XML 文件中的 EditText 块中:

        android:inputType="phone"
        android:digits="1234567890"

OR要么

        android:inputType="number"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM