Spannable 和 Editable、SpannableString 和 SpannableString
阿新 • • 發佈:2018-12-12
Spanned(可附加標記的字元序列)
**
* This is the interface for text that has markup objects attached to
* ranges of it. Not all text classes have mutable markup or text;
* see {@link Spannable} for mutable markup and {@link Editable} for
* mutable text.
*/
public interface Spanned
extends CharSequence
Spannable (可加或去除標記的字元序列)
/**
* This is the interface for text to which markup objects can be attached and detached.
* Not all Spannable classes have mutable text;
* see {@link Editable} for that.
*/
public interface Spannable
extends Spanned
Editable (內容和標記都可變的字元序列)
/** * This is the interface for text whose content and markup can be changed */ public interface Editable extends CharSequence, GetChars, Spannable, Appendable
Appendable(字元文字可改變的介面)
/**
* An object to which <tt>char</tt> sequences and values can be appended.
*/
public interface Appendable
SpannableString (內容不可變,標記可附加或去掉)
/** * This is the class for text whose content is immutable but to which * markup objects can be attached and detached. * For mutable text, see {@link SpannableStringBuilder}. */ public class SpannableString extends SpannableStringInternal implements CharSequence, GetChars, Spannable
SpannableString只有以下3個方法
public void setSpan(Object what, int start, int end, int flags) {
super.setSpan(what, start, end, flags);
}
public void removeSpan(Object what) {
super.removeSpan(what);
}
public final CharSequence subSequence(int start, int end) {
return new SpannableString(this, start, end);
}
SpannableStringBuilder(內容和標記都可變)
/**
* This is the class for text whose content and markup can both be changed.
*/
public class SpannableStringBuilder implements CharSequence, GetChars, Spannable, Editable,
Appendable, GraphicsOperations
SpannableStringBuilder有append,insert, setSpan , removeSpan方法