问题标签 [android-textwatcher]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - TextWatcher 中的 IndexOutOfBoundsException
在我的应用程序中,我想跟踪EditText
. 每次用户修改EditText
我要跟踪的字符时:
- 如果添加/删除了一个字符
- 添加/删除字符的索引处和
- 添加/删除了什么字符
我用TextWatcher
它来实现这一点。到目前为止,我的方法一直运行良好。但最近我IndexOutOfBoundsException
的生产应用程序发生了 3 次崩溃。我注意到的一件事是所有崩溃都发生在操作系统版本为 6.0.1 的 Galaxy S7 上。
我正在尝试找出一种理解和修复此崩溃的好方法。请参考下面的代码
到目前为止的 3 次崩溃是:
查看异常中的索引,我假设addCharIndex
没有正确计算。这意味着要么我对参数的理解beforeTextChanged
不正确,要么TextWatcher
方法没有按预期顺序调用,或者它们被多次调用并更新了参数,这弄乱了我计算addCharIndex
in的逻辑beforeTextChanged
。
任何有关如何解决此问题的帮助和见解将不胜感激。
谢谢。
android - 使用 TextWatcher 将文本用作图形数据
我正在创建一个脉搏率监测应用程序。脉率以实时变化的文本显示。我想将脉搏率显示为图表。如何使用 TextWatcher 从文本中绘制脉搏率图表?
java - 验证Android后带有TextWatcher的EditText重复
我有一个EditText
带有掩码“##-###.###”的结果是11-111.111,所以我决定使用TextWatch,所以我做了..
这将消耗一个WebService,但只是为了测试,带有OK消息的Toast执行两次,我不知道为什么......
android - android中的TextWatcher警告和慢速输入
我想改变在android中输入一个字符。如果用户类型space
或-
它将更改为_
所以我尝试了:
它“有效”,但如果用户输入速度很快,一些字母将不会出现,我会收到一些警告:
有什么想法有什么问题吗?
java - 我的应用程序由于 afterTextChanged 在输入字段中的退格键而崩溃,我如何处理此代码的退格键
这是我的 afterchangetext 的代码,当检测到空格时,它将前一个单词更改为其标准形式,但是当用户写一些东西并尝试删除或点击退格键时,应用程序由于这种方法而崩溃,请帮助我如何处理退格键
android - 如何使用 TextChanger 使我的按钮变得可见?
我在 xml 中制作了一个不可见的按钮,当我的 EditText 中的某个字符串值被制作时,我想让按钮再次可见。当使用 if 语句满足值时,我使用了 TextWatcher 检查。但是,当执行显示按钮的代码时,应用程序崩溃说 textwatcher 停止工作。我对android开发很陌生,所以可能是我搞砸了。
这是我的代码:
android - How to debug textwatcher in android app?
I am working on a MultiAutoCompleteTextView mactv
. My purpose is to read every word added in the mactv
during typing and do somethings with that word. For this, I am using TextWatcher to read the last word whenever space is typed in the mactv
. The logic for this is implemented in afterTextChanged()
method. But its not working correctly. So, I want to debug the app while inputting text in mactv
, but the app is crashing after the first call of afterTextChanged()
method.
I have already set breakpoints before setContentView()
methods of mainActivity and present Activity.
So, is there a way to debug this TextWatcher or to achieve this purpose by some other way?
Note: I have created a custom tokenizer which puts only space when items are clicked in auto complete list. And app is not crashing during normal run.
android - 如何在android中实现TextWatcher的一种方法?
我有一个应用程序,其中有很多编辑文本,但在某些编辑文本中,我只想实现 TextWatcher 的一种方法。我该怎么做那个好心的指导。
代码:-
android - Android - EditText TextWatcher 保持小写,不能保持插入符号(输入光标)位置
我有一个表单,用户可以在其中输入一些数据 EditText 字段。其中一个 EditText 小部件用于电子邮件地址。我正在使用 TextWatcher 来确保文本始终为小写,如下所示:
在onTextChanged(...)
我还进行比较以确保删除工作正常。
现在来解决问题。txtEmail.setText(temp);
导致整个观察者递归运行。txtEmail.setSelection(temp.length());
我可以通过添加和转义递归循环来控制插入符号位置到 EditText 的末尾,if
但是我找不到将插入符号保持在特定点的方法。例如,如果我写了“myema(il missing)@something.com”并想在输入的每个字母处返回以进行更正,则插入符号位于字符串的末尾。
现在奇怪的部分。我尝试将插入符号的位置保持在beforeTextChanged(...)
or之前onTextChanged(...)
。在我输入某些内容的那一刻,插入符号的位置在每种情况下都会正确更改。但是,当我们进入递归调用时,插入符号的位置报告为 0。我猜当我实际键入时,插入符号的移动也被注册了,但是因为在递归调用中没有插入符号移动而不是“粘贴” " EditText 中的文本我没有得到位置变化。
因此问题是:我怎样才能保持插入符号的位置?我的想法是实际上对文本进行子串化。将所有内容都放到插入符号中,使更改与 the 一起扔到那里,txtEmail.setSelection(temp.length());
然后在 else 步骤中附加字符串的其余部分(目前尚未尝试)。有没有其他(更简单/有效)的方法可以使用内置工具来处理?
提前致谢!
android - 在 OnTextChanged() 中设置文本后滞后
下面是一个复制我的滞后问题的示例。一旦我在 EditTextView 上设置了文本,至少需要 1.5 秒才能允许用户输入另一个字符。
我四处寻找并没有找到解决方案。