Android 退格/删除字符后缺少点击
我是 Android 新手,可能在这里缺少一些简单的东西...
我有一个 TextWatcher,正在监视 EditText 框。出于测试目的,我有以下代码,它除了清除 EditText 框之外什么也不做,然后重写原始的 EditText 内容。
public void afterTextChanged(Editable s){
mCheckAmount.removeTextChangedListener(this);
mCheckAmount.setText(""); //Clear EditText box
mCheckAmount.setText(s.toString()); //Write the string back
mCheckAmount.addTextChangedListener(this);
}
这在模拟器中工作得很好。
当我将其发送到手机(带有 2.2.2 的原始 Droid)时,我可以在 EditText 中输入数字(我将其设置为仅接受数字)。如果我从 EditText 框中删除单个数字,则必须在它出现之前输入新数字两次。换句话说,从 EditText 中删除一个字符后,下一次单击将被忽略。
我不知道我哪里出了问题。
预先感谢您的任何帮助。
I'm new to Android, probably missing something simple here...
I have a TextWatcher
, watching an EditText box. For test purposes, I have the following code, which does nothing but clear the EditText box, then rewrite the original EditText contents.
public void afterTextChanged(Editable s){
mCheckAmount.removeTextChangedListener(this);
mCheckAmount.setText(""); //Clear EditText box
mCheckAmount.setText(s.toString()); //Write the string back
mCheckAmount.addTextChangedListener(this);
}
This works fine in the emulator.
When I send it to the phone (Original Droid with 2.2.2 on it) I can enter numbers into the EditText (I have it set to only accept numbers). If I delete a single digit from the EditText box, I have to enter a new digit TWO times before it appears. In other words, after deleting a character from the EditText, the next click is ignored.
I have no idea where I am going wrong with this.
Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论