如何在 android EditText 中强制使用英文键盘

How to force English keyboard in android EditText(如何在 android EditText 中强制使用英文键盘)
本文介绍了如何在 android EditText 中强制使用英文键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我知道如何强制输入数字、文本等,但是如果我的数据库字段只能接受英文字符,是否有一个标志或 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 中强制使用英文键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
cocos2d-android: how to display score(cocos2d-android:如何显示分数)
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
Android file copy(安卓文件拷贝)
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)