安卓:从虚拟键盘按键阻塞 [英] Android: Blocking keys from virtual keyboard

查看:178
本文介绍了安卓:从虚拟键盘按键阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想允许用户输入只有某些字符星系标签(Android 2.2)上一个EditText,但阻止所有其他字符。一个OnKeyListener似乎没有对软键盘反应。

I want to allow the user to enter only certain characters to an EditText on a galaxy tab (Android 2.2) but block all other characters. An OnKeyListener seems not to react to the software keyboard.

PS:我不想要阻止的字符全部范围,像所有的数字或所有特殊字符等等。比方说,只是字符'T'。

PS: I dont want to block entire ranges of characters, like all digits or all special chars and so on. Let's say just the character 't'.

请帮忙。一个小时后,我无法找到一个解决方案。

Please help. After an hour I couldn't find a solution.

推荐答案

我相信你所需要的好奇和不一致的命名的 TextWatcher ,然后调用<一个href=\"http://developer.android.com/reference/android/widget/TextView.html#addTextChangedListener%28android.text.TextWatcher%29\"相对=nofollow> EditText.addTextChangedListener() 它。

I believe you need the curiously and inconsistently named TextWatcher, and then call EditText.addTextChangedListener() with it.

这篇关于安卓:从虚拟键盘按键阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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