问题标签 [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.
android - 如何在android中的多个编辑文本上添加文本观察器?
我有一个包含两个编辑文本的活动,并且TextWatcher
在该活动中有一个单独实现的活动。我想创建一个在该编辑文本中实现TextWatcher
的类。TextWatcher
我该怎么做那个代码: -
android - 实时文本更改 (Edittext)Android
在 Edittext 上,当用户键入内容时,我在除第一行之外的行的最后添加“#”,我还添加了 digits="1234567890#" 以仅允许数字。这是代码
但是这个问题是当用户输入任何东西时,它的光标会移动到行首。
此外,当用户在光标位于“#”之间时按下软键盘上的 del 时,它应该删除该行的最后一位,并且光标应该移动到它的附近。
请帮忙。
编辑
现在光标工作正常,除了退格键
java - EditText's onTextChanged being called with empty value on row recycle
I have a RecyclerView with an EditText in each row. Each EditText has a TextWatcher attached to it and an object in an array to store information about the row and the value of the EditText.
The problem I'm facing is that when the row goes offscreen, it gets recycled, but in that process, onTextChanged is called with an empty string, meaning an empty string is being saved to the row's information object. When that row is loaded again, it just loads a blank value, effectively deleting whatever content was in the EditText before. This seems like very useless functionality, because (as far as I can tell) there's no way to differentiate between a recycle clear and the user actually clearing the value in the EditText, making EditTexts in a RecyclerView completely useless.
my onBindViewHolder
method is this:
My TextWatcher is this:
android - 常见的 TextWatcher 类
我有 8 个片段,每个片段都使用包含在 TextInputLayout 中的 EditText 来扩展布局。在 onCreateView 中,正在实施
我还必须在每个片段主体中实现 MyTextWatcher 类,如下所示:
其中验证名称();
有没有办法让某个地方只有一个 MyTextWatcher 类和一个 validateName() 方法由每个片段调用,而不是重复相同的类/方法 8 次。谢谢
这是将 TextWatcher 类放置在 BaseDialogFragment 中的正确方法吗?
TextWatcher 的 beforeTextChanged 和 afterTextChanged 方法有什么逻辑?
android - Android:文本观察器 onTextChanged 和 afterTextChanged 事件多次触发。
我在编辑文本上使用文本观察器,并且该编辑文本位于列表视图内。我必须在编辑文本长度 == 3 时调用一个方法。但是文本观察器事件执行的次数不止一次。这是我的代码:
这是我的日志输出,其中计数消息重复
请一些人帮助我限制文本观察事件的多次执行。提前致谢。
android - 使 Single EditText 的输入在不同的视图中显示不同的输出
我有一个 EditText 字段和两个 ListViews。我想在 EditText 中输入数据并在 ListViews 上显示两个不同的结果。例如,第一个 ListView 显示以输入开头的单词,第二个 ListView 显示包含我输入的单词。
为此,我有 2 个自定义 ArrayAdapter。单独它们工作得很好,但是如果我尝试在 TextWatcher 中一起使用它们,它就会开始出现很多错误。这有什么问题?实现我所描述的功能的最佳方式是什么?
提前致谢。
这是我的 TextWatcher 的代码:
UPD: 这是我的适配器 + 过滤器代码。
}
android - android中TextChanged之前的空指针异常
它给了我空指针异常,我已经初始化了添加的 textwatcher,但我仍然有这个异常。我是不是忘记了什么。
任何帮助表示赞赏。
java - 按下按钮后如何更新方法以从 textwatcher 返回更新的信息
我已经声明了我的变量,'changed' too null 以便我可以检查它是否在编辑文本更改时发生更改,
我认为的问题是,当我按下保存按钮或取消按钮时,它总是会产生 null 值,因为单击按钮时它仍然为 null。但是,我认为 textwatcher 会监听 EditText 并且即使 EditText 中没有任何更改,默认情况下它也会将 SetChanged() 更改为 false,因为它提供了“实时更新”,但显然情况并非如此,我我做错了什么?还是我应该以不同的方式处理它?有什么方法可以刷新它吗?
建议将不胜感激。
(PS 删除了一些代码以减小大小并使其看起来更容易看,所以请原谅我缺少任何大括号。此外,活动确实运行正常,因为它显示了布局。但是在按下任何按钮时都会导致它坠毁。)
android-edittext - Android:在一定长度后限制editText条目
嗨我在编辑文本上使用文本观察器我想在一定长度后限制数字
我该如何使用 TextWatcher。
还尝试限制除点以外的所有关键条目但不起作用
java - 当 setText on editText TextWatcher.onTextChanged 没有被调用
每当EditText
更改字符串时,onTextChanged
都会调用。
现在,当我开始一个新的Activity
并通过发送数据时Bundle
,onTextChanged
不会调用。
我怎么称呼它?