Android Editable

本文介绍了Android中Editable接口的用途,重点讲解了replace、insert、delete和append等方法的功能和应用场景。Editable是用于可编辑文本的接口,常在EditText和TextView中使用。通过replace方法进行文本替换,insert用于插入文本,delete实现删除操作,而append则用于追加文本。此外,还提到了Editable的其他方法如clear、clearSpans和过滤器设置。
摘要由CSDN通过智能技术生成

简单记一下,以前没怎么用过。

EditText View的getText直接返回的就是 Editable

而 TextView则是getEditableText才返回 Editable。

还有就是注释所说,

* Replaces the specified range (<code>st&hellip;en</code>) of text in this
* Editable with a copy of the slice <code>start&hellip;end</code> from
* <code>source</code>.  The destination slice may be empty, in which case
* the operation is an insertion, or the source slice may be empty,
* in which case the operation is a deletion.

replace 在 没有选中内容时 表现为 insert操作,

replace/insert 的String 参数 不能为空.


android.text
接口 Editable

所有超级接口:
Appendable, CharSequence, GetChars, Spannable, Spanned
所有已知实现类:
SpannableStringBuilder

public interface Editable
   
   
    
    extends CharSequence, GetChars, Spannable, Appendable
   
   

This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). If you make a DynamicLayout of an Editable, the layout will be reflowed as the text is changed.


嵌套类摘要
static class Editable.Factory
          Factory used by TextView to create new Editables.
 
字段摘要
 
从接口 android.text.Spanned 继承的字段
SPAN_COMPOSING, SPAN_EXCLUSIVE_EXCLUSIVE, SPAN_EXCLUSIVE_INCLUSIVE, SPAN_INCLUSIVE_EXCLUSIVE, SPAN_INCLUSIVE_INCLUSIVE, SPAN_INTERMEDIATE, SPAN_MARK_MARK, SPAN_MARK_POINT, SPAN_PARAGRAPH, SPAN_POINT_MARK, SPAN_POINT_MARK_MASK, SPAN_POINT_POINT, SPAN_PRIORITY, SPAN_PRIORITY_SHIFT, SPAN_USER, SPAN_USER_SHIFT
 
方法摘要
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值