当前位置:网站首页>Spannable and editable, spannablestring and spannablestring

Spannable and editable, spannablestring and spannablestring

2022-06-25 11:15:00 User 9854323

Spanned( A sequence of characters that can be tagged )

**
 * 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 ( A sequence of characters that can be marked or removed )

/**
*  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 ( A sequence of characters with variable contents and marks )

/**
 * This is the interface for text whose content and markup can be changed 
 */
public interface Editable
extends CharSequence, GetChars, Spannable, Appendable

Appendable( Character text changeable interface )

/**
 * An object to which <tt>char</tt> sequences and values can be appended.
 */
public interface Appendable 

SpannableString ( The content is immutable , Markings may be attached or removed )

/**
 * 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 Only the following 3 A way

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( Content and markup are variable )

/**
 * 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 Yes append,insert, setSpan , removeSpan Method

原网站

版权声明
本文为[User 9854323]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251056179109.html