The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame^] | 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…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 Spannables. You can subclass |
| 50 | * it to provide something other than SpannableString. |
| 51 | */ |
| 52 | public static class Factory { |
| 53 | private static Spannable.Factory sInstance = new Spannable.Factory(); |
| 54 | |
| 55 | /** |
| 56 | * Returns the standard Spannable Factory. |
| 57 | */ |
| 58 | public static Spannable.Factory getInstance() { |
| 59 | return sInstance; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns a new SpannableString from the specified CharSequence. |
| 64 | * You can override this to provide a different kind of Spannable. |
| 65 | */ |
| 66 | public Spannable newSpannable(CharSequence source) { |
| 67 | return new SpannableString(source); |
| 68 | } |
| 69 | } |
| 70 | } |