Android Editable
简单记一下,以前没怎么用过。
EditText View的getText直接返回的就是 Editable
而 TextView则是getEditableText才返回 Editable。
还有就是注释所说,
* Replaces the specified range (<code>st…en</code>) of text in this
* Editable with a copy of the slice <code>start…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 Editableextends 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
|
方法摘要 | |
---|---|
Editable
|
append(char text) Convenience for append(String.valueOf(text)). |
Editable
|
append(CharSequence text) Convenience for replace(length(), length(), text, 0, text.length()) |
Editable
|
append(CharSequence text, int start, int end) Convenience for replace(length(), length(), text, start, end) |
void
|
clear() Convenience for replace(0, length(), "", 0, 0) |
void
|
clearSpans() Removes all spans from the Editable, as if by calling Spannable.removeSpan(java.lang.Object) on each of them. |
Editable
|
delete(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. |
Editable
|
insert(int where, CharSequence text) Convenience for replace(where, where, text, 0, text.length()); |
Editable
|
insert(int where, CharSequence text, int start, int end) Convenience for replace(where, where, text, start, end) |
Editable
|
replace(int st, int en, CharSequence text) Convenience for replace(st, en, text, 0, text.length()) |
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 .
|
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. |
从接口 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 slicestart…end
fromsource
. 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 ofcsq
that is appended. -
end
- the last index of the subsequence ofcsq
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.
Android Editable相关推荐
- android:editable=quot;falsequot;,如何在代码中复制android:editable =“false”?
我认为拒绝所有更改的InputFilter是一个很好的解决scheme: editText.setFilters(new InputFilter[] { new InputFilter() { pub ...
- android editable接口,Spannable与Editable区别
在看TextView源码时候又看到了这两个接口:Spannable和Editable: 之前一直没有认真研究过两者的关系,现在看了源码记录下来. 1:两者属于继承关系,Editable继承于Spann ...
- android 布局之RelativeLayout(相对布局)
android 布局分为LinearLayout TableLayout RelativeLayout FreamLayout AbsoluteLayout. 常用的有LinearLayout,Tab ...
- android c聊天功能,Android实现简单C/S聊天室应用
Android的网络应用:简单的C/S聊天室,供大家参考,具体内容如下 服务器端:提供两个类 创建ServerSocket监听的主类:MyServer.java 负责处理每个Socket通信的线程类: ...
- android edittext限制字节_android EditText输入限制
zyz 发表于 2012-5-30 18:19:03 android EditText输入限制 android:digits="1234567890.+-*/%\n()" 限制输入 ...
- android 弹出键盘 底部控件上移,如何设置底部控件view随着软键盘的弹出而上移...
1. 概述 在开发中,我们可能会遇到一个常见的效果,就是点击EditText输入框,软键盘随着EditText输入框同时上移,实现方式如下: 给EditText 外层添加一个 ScrollView,然 ...
- android中DatePicker和TimePicker的使用
先来看看效果图吧: 下面来贴出代码吧,其中main.xml代码为: <?xml version="1.0" encoding="utf-8"?> & ...
- android控件之TextView(一)
一.TextView 1.1 结构 java.lang.Object android.view.View android.widget.TextView 直接子类: Button, CheckedTe ...
- Android的一些属性使用
android:marqueeRepeatLimit="marquee_forever" //表示用不停止滚动 android:descendantFocusability=&qu ...
最新文章
- 微服务注册中心的选型和思考
- 多线程访问共享对象和数据的方式
- redis安装 linux步骤,【linux安装redis完整步骤】
- java模拟器apk闪退_急,求帮助,eclipse生成apk安装以后闪退
- hdu 2897(威佐夫博奕变形)
- ios多线程Android,iOS 关于多线程
- matlab 移动平均_两所高校被禁用MATLAB背后,是工业设计能力之争
- JAVA-进行Java Web项目开发需要掌握的技术
- Mysql net start mysql启动,提示发生系统错误 5 拒绝訪问 解决之道
- Linux表示什么、如何使用、在哪里使用、解释、简单操作
- 项目创新特色概述及主要内容
- #9733;用辩证数学解答“缸中之脑”
- 【BZOJ4414】数量积
- 2021金山wps校招(前端)
- Android中的事件处理总结
- 平面设计中负空间的意思是什么?如何设计?
- ad电阻原理图_arduino传感器专辑之光敏电阻模块
- android 相册view,Android直接把当前View保存到相册
- MindMapper中思维导图怎样实现合并
- 1011: 圆柱体表面积 Java