问题描述
更新:实际上,这不是Asus Phone的问题,而是Asus ZenUI键盘的问题.您可以安装键盘来解决该问题.我已经安装了Google Keyboard并测试过Zenfone 2.我的TextWatcher
中的所有内容都可以正常工作.但这不是错误修复或问题解决方案.
Update: actually, this is not a problem with Asus Phones, it's a problem with Asus ZenUI's keyboard. You can install a keyboard you like to walk around the problem. I have tested Zenfone 2 with Google Keyboard installed. Everything in my TextWatcher
works fine. But it is not a bug fix or problem solution.
我的EditText
上有两个InputFilter
和一个TextWatcher
.
InputFilters
:标准InputFilter.AllCaps()
过滤器和自定义仅限字母字符".他们就像魔术一样.
InputFilters
: standard InputFilter.AllCaps()
filter and custom 'alphabet characetrs only'. They works as magic.
TextWatcher
进行一些文本转换,(将符号从俄语音译为英语). TextWatcher
也可以正常工作,但不能在Asus手机上使用(在Zenfone 4和5上测试). Nexus 5,Genymotion仿真器和Samsung设备都可以.
TextWatcher
makes some text transofrmations (transliterates symbols from Russian into English). TextWatcher
also works fine but not on Asus phones (tested on Zenfone 4 and 5). Nexus 5, Genymotion emulator and Samsung device is OK.
问题是华硕手机不允许输入多个符号. TextWatcher
或setSelection()
可能有问题(禁用TextWatcher
时,在华硕上一切正常).
The problem is that Asus phone not allows to enter more than one symbol. Probably, there is a problem with TextWatcher
or setSelection()
(everything works fine on Asus when TextWatcher
is disabled).
TextView
的列表:
etCardholder.setFilters(new InputFilter[]{new InputFilter.AllCaps(), new NameInputeFilter(false)});
twTransliterator = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
etCardholder.removeTextChangedListener(twTransliterator);
etCardholder.setText(StringTools.transliterateCharacterRuToEn(s.toString()));
etCardholder.addTextChangedListener(twTransliterator);
}
@Override
public void afterTextChanged(Editable s) {
etCardholder.setSelection(etCardholder.getText().length());
validateCardData();
}
};
etCardholder.addTextChangedListener(twTransliterator);
我尝试不使用setSelection()
设置光标的位置,而是改用append()
.这里的结果相同.
I've tried not to set cursor's position with setSelection()
, but use append()
instead. Same results here.
您有什么可能的想法吗?以及如何走动呢?
Do you have any ideas what probably it can be? And how to walk around it?
推荐答案
我找到了解决此问题的方法,我的情况是EditText上的inputType属性带有以下参数:textCapCharacters,我使用textNoSuggestions进行解析.您也可以将两者与管道运算符'|'一起使用.
I found a solution for this problem, in my case was the inputType attribute on EditText was with the param: textCapCharacters, and i resolve using the textNoSuggestions. You can also use both with the pipe operator '|'.
android:inputType="textCapCharacters|textNoSuggestions"
这篇关于华硕Zenfone(Android)TextView \ TextWatcher键盘输入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!