Android Editable

2023-05-16

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

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 classEditable.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
 
方法摘要
 Editableappend(char text)
          Convenience for append(String.valueOf(text)).
 Editableappend(CharSequence text)
          Convenience for replace(length(), length(), text, 0, text.length())
 Editableappend(CharSequence text, int start, int end)
          Convenience for replace(length(), length(), text, start, end)
 voidclear()
          Convenience for replace(0, length(), "", 0, 0)
 voidclearSpans()
          Removes all spans from the Editable, as if by calling Spannable.removeSpan(java.lang.Object) on each of them.
 Editabledelete(int st, int en)
          Convenience for replace(st, en, "", 0, 0)
 InputFilter[]getFilters()
          Returns the array of input filters that are currently applied to changes to this Editable.
 Editableinsert(int where, CharSequence text)
          Convenience for replace(where, where, text, 0, text.length());
 Editableinsert(int where, CharSequence text, int start, int end)
          Convenience for replace(where, where, text, start, end)
 Editablereplace(int st, int en, CharSequence text)
          Convenience for replace(st, en, text, 0, text.length())
 Editablereplace(int st, int en, CharSequence source, int start, int end)
          Replaces the specified range (st…en) of text in this Editable with a copy of the slice start…end from source.
 voidsetFilters(InputFilter[] filters)
          Sets the series of filters that will be called in succession whenever the text of this Editable is changed, each of which has the opportunity to limit or transform the text that is being inserted.
 
从接口 android.text.GetChars 继承的方法
getChars
 
从接口 android.text.Spannable 继承的方法
removeSpan, setSpan
 
从接口 android.text.Spanned 继承的方法
getSpanEnd, getSpanFlags, getSpans, getSpanStart, nextSpanTransition
 
从接口 java.lang.CharSequence 继承的方法
charAt, length, subSequence, toString
 

方法详细信息

replace


Editable replace(int st,
                 int en,
                 CharSequence source,
                 int start,
                 int end)  
Replaces the specified range ( st…en) of text in this Editable with a copy of the slice start…end from source. 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.

Before the change is committed, each filter that was set with setFilters(android.text.InputFilter[]) is given the opportunity to modify the source text.

If source is Spanned, the spans from it are preserved into the Editable. Existing spans within the Editable that entirely cover the replaced range are retained, but any that were strictly within the range that was replaced are removed. As a special case, the cursor position is preserved even when the entire range where it is located is replaced.

返回:
a reference to this object.

replace


Editable replace(int st,
                 int en,
                 CharSequence text)  
Convenience for replace(st, en, text, 0, text.length())

另请参见:
replace(int, int, CharSequence, int, int)

insert


Editable insert(int where,
                CharSequence text,
                int start,
                int end)  
Convenience for replace(where, where, text, start, end)

另请参见:
replace(int, int, CharSequence, int, int)

insert


Editable insert(int where,
                CharSequence text)  
Convenience for replace(where, where, text, 0, text.length());

另请参见:
replace(int, int, CharSequence, int, int)

delete


Editable delete(int st,
                int en)  
Convenience for replace(st, en, "", 0, 0)

另请参见:
replace(int, int, CharSequence, int, int)

append


Editable append(CharSequence text)  
Convenience for replace(length(), length(), text, 0, text.length())

指定者:
接口 Appendable 中的 append
参数:
text - the character sequence to append.
返回:
this Appendable.
另请参见:
replace(int, int, CharSequence, int, int)

append


Editable append(CharSequence text,
                int start,
                int end)  
Convenience for replace(length(), length(), text, start, end)

指定者:
接口 Appendable 中的 append
参数:
text - the character sequence to append.
start - the first index of the subsequence of csq that is appended.
end - the last index of the subsequence of csq that is appended.
返回:
this Appendable.
另请参见:
replace(int, int, CharSequence, int, int)

append


Editable append(char text)  
Convenience for append(String.valueOf(text)).

指定者:
接口 Appendable 中的 append
参数:
text - the character to append.
返回:
this Appendable.
另请参见:
replace(int, int, CharSequence, int, int)

clear


void clear()  
Convenience for replace(0, length(), "", 0, 0)

另请参见:
Note that this clears the text, not the spans; use {@link #clearSpans} if you need that.

clearSpans


void clearSpans()  
Removes all spans from the Editable, as if by calling Spannable.removeSpan(java.lang.Object) on each of them.


setFilters


void setFilters(InputFilter[] filters)  
Sets the series of filters that will be called in succession whenever the text of this Editable is changed, each of which has the opportunity to limit or transform the text that is being inserted.


getFilters


InputFilter[] getFilters()  
Returns the array of input filters that are currently appliedto changes to this Editable.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android Editable 的相关文章

随机推荐

  • 彻底理解Java反射以及动态代理中对反射的应用

    反射 Reflection 是 Java 的特征之一 xff0c 它允许运行中的 Java 程序获取自身的信息 xff0c 并且可以操作类或对象的内部属性 简而言之 xff0c 通过反射 xff0c 我们可以在运行时获得程序或程序集中每一个
  • 读懂消息队列:Kafka与RocketMQ

    3月份学完了极客时间的 消息列队高手课 专栏 xff0c 专栏讲解了许多消息队列的基础知识并且对Kafka与RocketMQ两种主流消息队列有精彩的对比分析 学完专栏后将所有要点整理为笔记记录下来 xff0c 其他相关知识也搜索了大量资料
  • ubuntu20.04设置静态IP地址

    ubuntu20 04 默认使用动态IP设置 xff0c 但有时我们需要为其设置静态IP 本文将带着大家彻底搞清楚ubuntu20 04的IP设置方法 如果你是在虚拟机中使用ubuntu20 04 并对虚拟机的网络设置有疑问的话请看本人的拙
  • Centos的repos文件中的$releasever和$basearch的取值

    查看CentOS Base repo部分内容 xff0c 文件路径 etc yum repos d CentOS Base repo base baseurl 61 http mirror centos org centos release
  • 如何用Redis实现分布式锁

    为什么需要分布式锁 在聊分布式锁之前 xff0c 有必要先解释一下 xff0c 为什么需要分布式锁 与分布式锁相对就的是单机锁 xff0c 我们在写多线程程序时 xff0c 避免同时操作一个共享变量产生数据问题 xff0c 通常会使用一把锁
  • AQS与Synchronized异曲同工的加锁流程

    在并发多线程的情况下 xff0c 为了保证数据安全性 xff0c 一般我们会对数据进行加锁 xff0c 通常使用Synchronized或者ReentrantLock同步锁 Synchronized是基于JVM实现 xff0c 而Reent
  • 基于贫血模型的MVC开发模式VS领域建模开发模式

    大部分工程师都是做业务开发的 xff0c 很多业务系统都是基于MVC三层架构来开发的 xff0c 确切点说 xff0c 这是一种基于贫血模型的MVC三层架构开发模式 这种开发模式已经成为标准的Web项目开发模式 xff0c 但它却违反了面向
  • 从Servlet、Servlet容器及Web容器的演进历程总结框架设计的套路

    Web架构演进历程 早期的Web技术主要用于浏览静态页面 xff0c 首先浏览器发起HTTP请求 xff0c 请求一些静态资源 xff0c 这时候需要一个服务器来处理HTTP请求 xff0c 并且将相应的静态资源返回 这个服务器叫HTTP服
  • 信号量与生产者消费者问题

    生产者 消费者问题 生产者 消费者题型在各类考试 xff08 考研 程序员证书 程序员面试笔试 期末考试 xff09 很常见 xff0c 原因之一是生产者 消费者题型在实际的并发程序 xff08 多进程 多线程 xff09 设计中很常见 x
  • IOC的实现原理—反射与工厂模式

    反射机制概念 我们考虑一个场景 xff0c 如果我们在程序运行时 xff0c 一个对象想要检视自己所拥有的成员属性 xff0c 该如何操作 xff1f 再考虑另一个场景 xff0c 如果我们想要在运行期获得某个类的Class信息如它的属性
  • Spring中bean的作用域与生命周期

    在Spring中 xff0c 那些组成应用程序的主体及由Spring IoC容器所管理的对象 xff0c 被称之为bean 简单地讲 xff0c bean就是由IoC容器初始化 装配及管理的对象 xff0c 除此之外 xff0c bean就
  • 前后端分离架构概述

    1 背景 前后端分离已成为互联网项目开发的业界标准使用方式 xff0c 通过nginx 43 tomcat的方式 xff08 也可以中间加一个nodejs xff09 有效的进行解耦 xff0c 并且前后端分离会为以后的大型分布式架构 弹性
  • 数据库的事务隔离级别总结

    学习数据库的时候常常会接触到事务 ACID等概念 xff0c 那么到底什么是数据库的事务 xff0c 数据库事务又具有哪些特点 xff0c 和ACID有怎样的关系 xff0c 事务的隔离级别又是做什么的呢 xff1f 事务及其四大特性 xf
  • ubuntu18 遇到libc6 版本冲突问题

    问题描述 xff1a You might want to run 39 apt fix broken install 39 to correct these The following packages have unmet depende
  • Linux 系统裁剪--制作一个最小化的Linux iso镜像

    1 前言 一直以来都想制作一个最小化的Linux系统 xff0c 这个小系统需要有常用的Linux 命令 xff0c 以及定制化的某些功能 可是由于种种原因一直没能实现 xff0c 最近终于有时间把它做了出来 本文所说的精简的Linux系统
  • git为单独的仓库设置提交的用户名

    在我们平时的学习中可能有这么一种需求 xff0c 在公司进行开发的时候 xff0c 一般会参与多个项目的开发 xff0c 而项目提交代码时 xff0c 一般请求情况下提供的用户都是同一个 xff0c 而我们为了方便可能会使用全局进行git
  • Ubuntu18.04安装Xfce桌面与VNC远程工具

    1 Xfce桌面的安装 Xfce是一款轻量级的桌面环境 xff0c 运行在类Unix操作系统 xff08 如Linux FreeBSD 和 Solaris xff09 上 xff0c 界面清爽美观且对用户友好 在安装Xfce前需要更新一下系
  • Nginx的临时文件权限问题

    问题 在重启了nginx发现部分较大的Post请求出现了500错误 xff0c 然后 xff0c 查看Nginx错误日志 xff0c 类似如下 xff1a nginx open 34 usr local nginx client body
  • Spring Security中启用CSRF防护(REST版)

    问题 之前文章 Spring Security 43 Spring Session Redis 43 JJWT 介绍了怎么使用Spring Security实现restful风格的登录api 现在 xff0c 我们在这个基础上面实现csrf
  • Android Editable

    简单记一下 xff0c 以前没怎么用过 EditText View的getText直接返回的就是 Editable 而 TextView则是getEditableText才返回 Editable 还有就是注释所说 Replaces the