问题描述
我需要一个被称为每次在一个EditText变化选择监听器。我用Google搜索周围,但我找不到任何的API级别7有用。我正在写一个文本编辑器,我想的粗体/斜体/下划线按钮显示为选中的每个用户选择粗体/斜体/下划线的文本的时间。
I need a listener which is called every time the selection in an EditText changes.I googled around but I couldn't find anything useful for API level 7.I'm writing a Text Editor and I want the bold/italic/underlined button appear selected every time the user selects bold/italic/underlined text.
推荐答案
更好的方式来做到这将是延长的EditText,然后根据你想如何管理不断变化的文字,你可以覆盖2之一方法制定出您的自定义的行为。
The better way to do it would be to extend the EditText and then based upon how you would want to manage the changing text, you could override one of the 2 methods to work out your customized behavior.
-
如果您想选择改变,那么你可以使用
onSelectionChanged()
办法和实施code那里。
If you want the selection changed then you could use the
onSelectionChanged()
method and implement your code there.
如果你想实现的东西当文本改变你的编辑器,那么你可以使用 onTextChanged()
。
In case you want to implement something when the text changes in your editor then you could use, onTextChanged()
.
这篇关于在Android的文本选择监听器(API 7级)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!