His*_*eer 23 java android textwatcher
我正在查看TextWatcher的源代码,我没有在这里得到这个概念.扩展到NoCopySpan有什么意义?
public interface TextWatcher extends NoCopySpan {
public void beforeTextChanged(CharSequence s, int start, int count, int after);
public void onTextChanged(CharSequence s, int start, int before, int count);
public void afterTextChanged(Editable s);
}
Run Code Online (Sandbox Code Playgroud)
package android.text;
/**
* This interface should be added to a span object that should not be copied into a new Spanned when performing a slice or copy operation on the original Spanned it was placed in.
*/
public interface NoCopySpan {
/**
* Convenience equivalent for when you would just want a new Object() for
* a span but want it to be no-copy. Use this instead.
*/
public class Concrete implements NoCopySpan {}
}
Run Code Online (Sandbox Code Playgroud)
vsm*_*kov 12
NoCopySpan只是一个标记界面.根据javadoc,它用于修改Spanned对象的复制例程的行为(它依赖于组件的类型).例如,android.text.SpannableStringBuilder使用此类继承信息来跳过跨构造时的复制.
这种方法有一些缺点,但仍然很常见.Concrete类存在的原因是提供构造接口的on-op虚拟(或默认)实现的便捷方式NoCopySpan.
| 归档时间: |
|
| 查看次数: |
439 次 |
| 最近记录: |