Home | History | Annotate | Download | only in text
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.text;
     18 
     19 /**
     20  * This is the interface for text to which markup objects can be
     21  * attached and detached.  Not all Spannable classes have mutable text;
     22  * see {@link Editable} for that.
     23  */
     24 public interface Spannable
     25 extends Spanned
     26 {
     27     /**
     28      * Attach the specified markup object to the range <code>start&hellip;end</code>
     29      * of the text, or move the object to that range if it was already
     30      * attached elsewhere.  See {@link Spanned} for an explanation of
     31      * what the flags mean.  The object can be one that has meaning only
     32      * within your application, or it can be one that the text system will
     33      * use to affect text display or behavior.  Some noteworthy ones are
     34      * the subclasses of {@link android.text.style.CharacterStyle} and
     35      * {@link android.text.style.ParagraphStyle}, and
     36      * {@link android.text.TextWatcher} and
     37      * {@link android.text.SpanWatcher}.
     38      */
     39     public void setSpan(Object what, int start, int end, int flags);
     40 
     41     /**
     42      * Remove the specified object from the range of text to which it
     43      * was attached, if any.  It is OK to remove an object that was never
     44      * attached in the first place.
     45      */
     46     public void removeSpan(Object what);
     47 
     48     /**
     49      * Factory used by TextView to create new {@link Spannable Spannables}. You can subclass
     50      * it to provide something other than {@link SpannableString}.
     51      *
     52      * @see android.widget.TextView#setSpannableFactory(Factory)
     53      */
     54     public static class Factory {
     55         private static Spannable.Factory sInstance = new Spannable.Factory();
     56 
     57         /**
     58          * Returns the standard Spannable Factory.
     59          */
     60         public static Spannable.Factory getInstance() {
     61             return sInstance;
     62         }
     63 
     64         /**
     65          * Returns a new SpannableString from the specified CharSequence.
     66          * You can override this to provide a different kind of Spannable.
     67          */
     68         public Spannable newSpannable(CharSequence source) {
     69             return new SpannableString(source);
     70         }
     71     }
     72 }
     73