java Android - 如何禁用虚拟键盘中的某些键

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11411608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 04:59:47  来源:igfitidea点击:

Android - How to disable certain keys in virtual keyboard

javaandroidkeyboard

提问by henrywibowo

How to disable certain keys (say number/symbol keys) in Android virtual keyboard?

如何禁用 Android 虚拟键盘中的某些键(比如数字/符号键)?

Specifically I want user can't input a double quote ( " ) character when virtual keyboard is showed up when user focus on a standard android EditText widget.

具体来说,当用户专注于标准的 android EditText 小部件时,我希望用户不能在虚拟键盘出现时输入双引号 (") 字符。

回答by CommonsWare

How to disable certain keys (say number/symbol keys) in Android virtual keyboard?

如何禁用 Android 虚拟键盘中的某些键(比如数字/符号键)?

You can't, sorry. After all, the input method editor may not have "keys" in the first place.

你不能,对不起。毕竟,输入法编辑器可能一开始就没有“键”。

Specifically I want user can't input a double quote ( " ) character when virtual keyboard is showed up when user focus on a standard android EditText widget.

具体来说,当用户专注于标准的 android EditText 小部件时,我希望用户不能在虚拟键盘出现时输入双引号 (") 字符。

Then you will have to block the input at the EditText, by means of an InputFilter, as is described here: How do I use InputFilter to limit characters in an EditText in Android?

然后,你将有权阻止在输入EditText,通过的手段InputFilter,因为这里描述:如何使用输入过滤器来限制字符一个EditText在Android中?

回答by ColdFire