问题描述
我想允许用户输入只有某些字符星系标签(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.
推荐答案
我相信你所需要的好奇和不一致的命名的,然后调用 EditText.addTextChangedListener()
它。
I believe you need the curiously and inconsistently named TextWatcher
, and then call EditText.addTextChangedListener()
with it.
这篇关于安卓:从虚拟键盘按键阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!