问题描述
我知道如何强制输入数字、文本等,但是如果我的数据库字段只能接受英文字符,是否有一个标志或 IME 选项让我强制 EditText 只接受某些语言,如英语?当然,我可以检查并通知用户输入错误,但这并不完全是用户友好的......
I know how to force numbers, texts etc.., but is there a flag or IME options for me to force the EditText to accept only certain language like English in case my DB fields can accept only English characters? of course I can check and notify the users on bad input but that's not exactly user friendly....
在 EditText 上实现我自己的过滤器也是可能的,但我不确定它是否会强制键盘布局本身使用我需要的语言.
Implementing my own filter on the EditText might also be possible but I'm not sure it will force the keyboard layout itself to be in the language I need.
有什么想法吗?
推荐答案
无论如何你都应该过滤输入.强制英文键盘不会强制用户只使用英文字母.用户仍然可以长按字符或使用非英文硬件键盘.
You should probably filter the input anyways. Forcing English keyboard doesn't force user to use only English letters. User can still long press a character or have a non-english hardware keyboard.
您可以收听文本更改事件并拒绝此时您的数据库不接受的所有字符.
You could listen to text change events and reject all characters that are not accepted by your DB at that point.
这篇关于如何在 android EditText 中强制使用英文键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)