Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android TextWatcher";onTextChanged“;方法问题_Android_Android Edittext - Fatal编程技术网

Android TextWatcher";onTextChanged“;方法问题

Android TextWatcher";onTextChanged“;方法问题,android,android-edittext,Android,Android Edittext,TextWatcher的onTextChanged方法中的count参数的行为根据是否为edittext设置了android:inputType属性而有所不同 如果设置了输入类型,则会给出输入的新字符计数,而不是edittext中的字符总数;如果未设置输入类型,则会给出edittext中的字符总数 这是一个bug还是我遗漏了什么?onTextChanged方法中的count给出了输入的新字符的计数。因此,android:inputTypeset的行为是正确的。 要获得字符的总长度,请在onTex

TextWatcher的onTextChanged方法中的count参数的行为根据是否为edittext设置了
android:inputType
属性而有所不同

如果设置了输入类型,则会给出输入的新字符计数,而不是edittext中的字符总数;如果未设置输入类型,则会给出edittext中的字符总数


这是一个bug还是我遗漏了什么?

onTextChanged方法中的count给出了输入的新字符的计数。因此,
android:inputType
set的行为是正确的。 要获得字符的总长度,请在onTextChanged方法中使用
s.length()

count给出编辑文本中总字符长度的奇怪行为可能是由于编辑文本的一些完整选择/建议造成的。

我上传了一个示例,您甚至可以下载它()。在editText中,用户最多可以输入10个字符。当用户输入/删除字符时,总长度将在textview中输出

 android:inputType set is correct. In order to get the total characters length use           s.length() inside the onTextChanged method

谢谢您的回复。问题不在于如何,而在于为什么?为什么为edittext设置了基于“input type”属性的同一方法的两种不同行为?谢谢您的回复。问题不在于如何,而在于为什么?为什么为edittext设置了基于“input type”属性的同一方法的两种不同行为