简体   繁体   English

如何打开Android键盘仅显示Android中的自定义数字

[英]How to open Android keyboard show only custom digits in Android

I want to show digits "0123456789/" on keyboard if open on click of SearchView but I don't know how it can be done. 如果要在单击SearchView时打开,我想在keyboard上显示数字“ 0123456789 /”,但我不知道该怎么做。 I am able to set InputType to a searchview like this 我可以将InputType设置为这样的searchview

searchView.setInputType(InputType.TYPE_CLASS_NUMBER);

but not able to set custom digit to show on a keyboard . 但无法设置自定义数字以显示在keyboard

from input type InputType.TYPE_CLASS_NUMBER numeric keyboard is opening but i also want to show "/" also with numeric digits 0123456789. I searched a lot on SO but didn't find any solution for this. 从输入类型InputType.TYPE_CLASS_NUMBER数字键盘打开,但是我也想显示数字0123456789的“ /”。我在SO上进行了大量搜索,但没有找到任何解决方案。

There is no easy solution for this. 对此没有简单的解决方案。 You have two options depending on what you can work with and what exactly you want. 您可以根据自己的工作方式和实际需要选择两个选项。

  1. If it is exactly as you say in your question, that is, to SHOW just the Characters that you specify, then the way to go about doing that would be to create a Custom SoftKeyboard . 如果它是完全按照你在你的问题,也就是说,只显示你指定的字符,然后去这样做,这将是创建的方式Custom SoftKeyboard This will allow you to take only the desired inputs and will show only those characters that you have specified. 这将允许您仅接受所需的输入,并且仅显示您指定的那些字符。
  2. Otherwise you can disable taking other characters input (that are not to be available), by working with [onQueryTextChanged] 1 where you manipulate to resend only the values that you can take in as input. 否则,您可以通过使用[onQueryTextChanged] 1来禁用其他字符输入(不可用),在该[onQueryTextChanged] 1上操作以仅重新发送可以输入的值。 Here the default softKeyboard is used, but the input taken in by the SearchView are as per specification. 这里使用默认的softKeyboard,但是SearchView接受的输入符合规范。

Note : my knowledge is mainly based on working with EditText rather than SearchView , so not able to provide exact codes for the above 注意:我的知识主要是基于使用EditText而不是SearchView ,因此无法为上述代码提供确切的代码

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

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