如何在Android EditText中强制英文键盘 [英] how to force english keyboard in android EditText

查看:846
本文介绍了如何在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中强制英文键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆