Loading core/java/android/text/Editable.java +4 −2 Original line number Diff line number Diff line Loading @@ -121,8 +121,10 @@ extends CharSequence, GetChars, Spannable, Appendable public InputFilter[] getFilters(); /** * Factory used by TextView to create new Editables. You can subclass * it to provide something other than SpannableStringBuilder. * Factory used by TextView to create new {@link Editable Editables}. You can subclass * it to provide something other than {@link SpannableStringBuilder}. * * @see android.widget.TextView#setEditableFactory(Factory) */ public static class Factory { private static Editable.Factory sInstance = new Editable.Factory(); Loading core/java/android/text/Spannable.java +5 −3 Original line number Diff line number Diff line Loading @@ -46,8 +46,10 @@ extends Spanned public void removeSpan(Object what); /** * Factory used by TextView to create new Spannables. You can subclass * it to provide something other than SpannableString. * Factory used by TextView to create new {@link Spannable Spannables}. You can subclass * it to provide something other than {@link SpannableString}. * * @see android.widget.TextView#setSpannableFactory(Factory) */ public static class Factory { private static Spannable.Factory sInstance = new Spannable.Factory(); Loading core/java/android/widget/TextView.java +122 −28 Original line number Diff line number Diff line Loading @@ -1683,12 +1683,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Return the text the TextView is displaying. If setText() was called with * an argument of BufferType.SPANNABLE or BufferType.EDITABLE, you can cast * Return the text that TextView is displaying. If {@link #setText(CharSequence)} was called * with an argument of {@link android.widget.TextView.BufferType#SPANNABLE BufferType.SPANNABLE} * or {@link android.widget.TextView.BufferType#EDITABLE BufferType.EDITABLE}, you can cast * the return value from this method to Spannable or Editable, respectively. * * Note: The content of the return value should not be modified. If you want * a modifiable one, you should make your own copy first. * <p/> * The content of the return value should not be modified. If you want a modifiable one, you * should make your own copy first. * * @attr ref android.R.styleable#TextView_text */ Loading @@ -1705,8 +1706,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Return the text the TextView is displaying as an Editable object. If * the text is not editable, null is returned. * Return the text that TextView is displaying as an Editable object. If the text is not * editable, null is returned. * * @see #getText */ Loading Loading @@ -4148,18 +4149,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Convenience method: Append the specified text to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was * not already editable. * Convenience method to append the specified text to the TextView's * display buffer, upgrading it to {@link android.widget.TextView.BufferType#EDITABLE} * if it was not already editable. * * @param text text to be appended to the already displayed text */ public final void append(CharSequence text) { append(text, 0, text.length()); } /** * Convenience method: Append the specified text slice to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was * not already editable. * Convenience method to append the specified text slice to the TextView's * display buffer, upgrading it to {@link android.widget.TextView.BufferType#EDITABLE} * if it was not already editable. * * @param text text to be appended to the already displayed text * @param start the index of the first character in the {@code text} * @param end the index of the character following the last character in the {@code text} * * @see Appendable#append(CharSequence, int, int) */ public void append(CharSequence text, int start, int end) { if (!(mText instanceof Editable)) { Loading Loading @@ -4403,7 +4412,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /////////////////////////////////////////////////////////////////////////// /** * Sets the Factory used to create new Editables. * Sets the Factory used to create new {@link Editable Editables}. * * @param factory {@link android.text.Editable.Factory Editable.Factory} to be used * * @see android.text.Editable.Factory * @see android.widget.TextView.BufferType#EDITABLE */ public final void setEditableFactory(Editable.Factory factory) { mEditableFactory = factory; Loading @@ -4411,7 +4425,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Sets the Factory used to create new Spannables. * Sets the Factory used to create new {@link Spannable Spannables}. * * @param factory {@link android.text.Spannable.Factory Spannable.Factory} to be used * * @see android.text.Spannable.Factory * @see android.widget.TextView.BufferType#SPANNABLE */ public final void setSpannableFactory(Spannable.Factory factory) { mSpannableFactory = factory; Loading @@ -4419,13 +4438,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Sets the string value of the TextView. TextView <em>does not</em> accept * Sets the text to be displayed. TextView <em>does not</em> accept * HTML-like formatting, which you can do with text strings in XML resource files. * To style your strings, attach android.text.style.* objects to a * {@link android.text.SpannableString SpannableString}, or see the * {@link android.text.SpannableString}, or see the * <a href="{@docRoot}guide/topics/resources/available-resources.html#stringresources"> * Available Resource Types</a> documentation for an example of setting * formatted text in the XML resource file. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text text to be displayed * * @attr ref android.R.styleable#TextView_text */ Loading @@ -4435,10 +4461,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Like {@link #setText(CharSequence)}, * except that the cursor position (if any) is retained in the new text. * Sets the text to be displayed but retains the cursor position. Same as * {@link #setText(CharSequence)} except that the cursor position (if any) is retained in the * new text. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text The new text to place in the text view. * @param text text to be displayed * * @see #setText(CharSequence) */ Loading @@ -4448,9 +4480,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Sets the text that this TextView is to display (see * {@link #setText(CharSequence)}) and also sets whether it is stored * in a styleable/spannable buffer and whether it is editable. * Sets the text to be displayed and the {@link android.widget.TextView.BufferType}. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text text to be displayed * @param type a {@link android.widget.TextView.BufferType} which defines whether the text is * stored as a static text, styleable/spannable text, or editable text * * @see #setText(CharSequence) * @see android.widget.TextView.BufferType * @see #setSpannableFactory(Spannable.Factory) * @see #setEditableFactory(Editable.Factory) * * @attr ref android.R.styleable#TextView_text * @attr ref android.R.styleable#TextView_bufferType Loading Loading @@ -4621,6 +4665,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * of the array except for right before another call to setText(), * since the TextView has no way to know that the text * has changed and that it needs to invalidate and re-layout. * * @param text char array to be displayed * @param start start index in the char array * @param len length of char count after {@code start} */ public final void setText(char[] text, int start, int len) { int oldlen = 0; Loading Loading @@ -4651,8 +4699,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Like {@link #setText(CharSequence, android.widget.TextView.BufferType)}, * except that the cursor position (if any) is retained in the new text. * Sets the text to be displayed and the {@link android.widget.TextView.BufferType} but retains * the cursor position. Same as * {@link #setText(CharSequence, android.widget.TextView.BufferType)} except that the cursor * position (if any) is retained in the new text. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text text to be displayed * @param type a {@link android.widget.TextView.BufferType} which defines whether the text is * stored as a static text, styleable/spannable text, or editable text * * @see #setText(CharSequence, android.widget.TextView.BufferType) */ Loading @@ -4672,11 +4731,42 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } /** * Sets the text to be displayed using a string resource identifier. * * @param resid the resource identifier of the string resource to be displayed * * @see #setText(CharSequence) * * @attr ref android.R.styleable#TextView_text */ @android.view.RemotableViewMethod public final void setText(@StringRes int resid) { setText(getContext().getResources().getText(resid)); } /** * Sets the text to be displayed using a string resource identifier and the * {@link android.widget.TextView.BufferType}. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param resid the resource identifier of the string resource to be displayed * @param type a {@link android.widget.TextView.BufferType} which defines whether the text is * stored as a static text, styleable/spannable text, or editable text * * @see #setText(int) * @see #setText(CharSequence) * @see android.widget.TextView.BufferType * @see #setSpannableFactory(Spannable.Factory) * @see #setEditableFactory(Editable.Factory) * * @attr ref android.R.styleable#TextView_text * @attr ref android.R.styleable#TextView_bufferType */ public final void setText(@StringRes int resid, BufferType type) { setText(getContext().getResources().getText(resid), type); } Loading Loading @@ -5110,7 +5200,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Set the extra input data of the text, which is the * {@link EditorInfo#extras TextBoxAttribute.extras} * Bundle that will be filled in when creating an input connection. The * given integer is the resource ID of an XML resource holding an * given integer is the resource identifier of an XML resource holding an * {@link android.R.styleable#InputExtras <input-extras>} XML tree. * * @see #getInputExtras(boolean) Loading Loading @@ -8832,8 +8922,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } /** * Type of the text buffer that defines the characteristics of the text such as static, * styleable, or editable. */ public enum BufferType { NORMAL, SPANNABLE, EDITABLE, NORMAL, SPANNABLE, EDITABLE } /** Loading Loading
core/java/android/text/Editable.java +4 −2 Original line number Diff line number Diff line Loading @@ -121,8 +121,10 @@ extends CharSequence, GetChars, Spannable, Appendable public InputFilter[] getFilters(); /** * Factory used by TextView to create new Editables. You can subclass * it to provide something other than SpannableStringBuilder. * Factory used by TextView to create new {@link Editable Editables}. You can subclass * it to provide something other than {@link SpannableStringBuilder}. * * @see android.widget.TextView#setEditableFactory(Factory) */ public static class Factory { private static Editable.Factory sInstance = new Editable.Factory(); Loading
core/java/android/text/Spannable.java +5 −3 Original line number Diff line number Diff line Loading @@ -46,8 +46,10 @@ extends Spanned public void removeSpan(Object what); /** * Factory used by TextView to create new Spannables. You can subclass * it to provide something other than SpannableString. * Factory used by TextView to create new {@link Spannable Spannables}. You can subclass * it to provide something other than {@link SpannableString}. * * @see android.widget.TextView#setSpannableFactory(Factory) */ public static class Factory { private static Spannable.Factory sInstance = new Spannable.Factory(); Loading
core/java/android/widget/TextView.java +122 −28 Original line number Diff line number Diff line Loading @@ -1683,12 +1683,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Return the text the TextView is displaying. If setText() was called with * an argument of BufferType.SPANNABLE or BufferType.EDITABLE, you can cast * Return the text that TextView is displaying. If {@link #setText(CharSequence)} was called * with an argument of {@link android.widget.TextView.BufferType#SPANNABLE BufferType.SPANNABLE} * or {@link android.widget.TextView.BufferType#EDITABLE BufferType.EDITABLE}, you can cast * the return value from this method to Spannable or Editable, respectively. * * Note: The content of the return value should not be modified. If you want * a modifiable one, you should make your own copy first. * <p/> * The content of the return value should not be modified. If you want a modifiable one, you * should make your own copy first. * * @attr ref android.R.styleable#TextView_text */ Loading @@ -1705,8 +1706,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Return the text the TextView is displaying as an Editable object. If * the text is not editable, null is returned. * Return the text that TextView is displaying as an Editable object. If the text is not * editable, null is returned. * * @see #getText */ Loading Loading @@ -4148,18 +4149,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Convenience method: Append the specified text to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was * not already editable. * Convenience method to append the specified text to the TextView's * display buffer, upgrading it to {@link android.widget.TextView.BufferType#EDITABLE} * if it was not already editable. * * @param text text to be appended to the already displayed text */ public final void append(CharSequence text) { append(text, 0, text.length()); } /** * Convenience method: Append the specified text slice to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was * not already editable. * Convenience method to append the specified text slice to the TextView's * display buffer, upgrading it to {@link android.widget.TextView.BufferType#EDITABLE} * if it was not already editable. * * @param text text to be appended to the already displayed text * @param start the index of the first character in the {@code text} * @param end the index of the character following the last character in the {@code text} * * @see Appendable#append(CharSequence, int, int) */ public void append(CharSequence text, int start, int end) { if (!(mText instanceof Editable)) { Loading Loading @@ -4403,7 +4412,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /////////////////////////////////////////////////////////////////////////// /** * Sets the Factory used to create new Editables. * Sets the Factory used to create new {@link Editable Editables}. * * @param factory {@link android.text.Editable.Factory Editable.Factory} to be used * * @see android.text.Editable.Factory * @see android.widget.TextView.BufferType#EDITABLE */ public final void setEditableFactory(Editable.Factory factory) { mEditableFactory = factory; Loading @@ -4411,7 +4425,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Sets the Factory used to create new Spannables. * Sets the Factory used to create new {@link Spannable Spannables}. * * @param factory {@link android.text.Spannable.Factory Spannable.Factory} to be used * * @see android.text.Spannable.Factory * @see android.widget.TextView.BufferType#SPANNABLE */ public final void setSpannableFactory(Spannable.Factory factory) { mSpannableFactory = factory; Loading @@ -4419,13 +4438,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Sets the string value of the TextView. TextView <em>does not</em> accept * Sets the text to be displayed. TextView <em>does not</em> accept * HTML-like formatting, which you can do with text strings in XML resource files. * To style your strings, attach android.text.style.* objects to a * {@link android.text.SpannableString SpannableString}, or see the * {@link android.text.SpannableString}, or see the * <a href="{@docRoot}guide/topics/resources/available-resources.html#stringresources"> * Available Resource Types</a> documentation for an example of setting * formatted text in the XML resource file. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text text to be displayed * * @attr ref android.R.styleable#TextView_text */ Loading @@ -4435,10 +4461,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Like {@link #setText(CharSequence)}, * except that the cursor position (if any) is retained in the new text. * Sets the text to be displayed but retains the cursor position. Same as * {@link #setText(CharSequence)} except that the cursor position (if any) is retained in the * new text. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text The new text to place in the text view. * @param text text to be displayed * * @see #setText(CharSequence) */ Loading @@ -4448,9 +4480,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Sets the text that this TextView is to display (see * {@link #setText(CharSequence)}) and also sets whether it is stored * in a styleable/spannable buffer and whether it is editable. * Sets the text to be displayed and the {@link android.widget.TextView.BufferType}. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text text to be displayed * @param type a {@link android.widget.TextView.BufferType} which defines whether the text is * stored as a static text, styleable/spannable text, or editable text * * @see #setText(CharSequence) * @see android.widget.TextView.BufferType * @see #setSpannableFactory(Spannable.Factory) * @see #setEditableFactory(Editable.Factory) * * @attr ref android.R.styleable#TextView_text * @attr ref android.R.styleable#TextView_bufferType Loading Loading @@ -4621,6 +4665,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * of the array except for right before another call to setText(), * since the TextView has no way to know that the text * has changed and that it needs to invalidate and re-layout. * * @param text char array to be displayed * @param start start index in the char array * @param len length of char count after {@code start} */ public final void setText(char[] text, int start, int len) { int oldlen = 0; Loading Loading @@ -4651,8 +4699,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** * Like {@link #setText(CharSequence, android.widget.TextView.BufferType)}, * except that the cursor position (if any) is retained in the new text. * Sets the text to be displayed and the {@link android.widget.TextView.BufferType} but retains * the cursor position. Same as * {@link #setText(CharSequence, android.widget.TextView.BufferType)} except that the cursor * position (if any) is retained in the new text. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param text text to be displayed * @param type a {@link android.widget.TextView.BufferType} which defines whether the text is * stored as a static text, styleable/spannable text, or editable text * * @see #setText(CharSequence, android.widget.TextView.BufferType) */ Loading @@ -4672,11 +4731,42 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } /** * Sets the text to be displayed using a string resource identifier. * * @param resid the resource identifier of the string resource to be displayed * * @see #setText(CharSequence) * * @attr ref android.R.styleable#TextView_text */ @android.view.RemotableViewMethod public final void setText(@StringRes int resid) { setText(getContext().getResources().getText(resid)); } /** * Sets the text to be displayed using a string resource identifier and the * {@link android.widget.TextView.BufferType}. * <p/> * When required, TextView will use {@link android.text.Spannable.Factory} to create final or * intermediate {@link Spannable Spannables}. Likewise it will use * {@link android.text.Editable.Factory} to create final or intermediate * {@link Editable Editables}. * * @param resid the resource identifier of the string resource to be displayed * @param type a {@link android.widget.TextView.BufferType} which defines whether the text is * stored as a static text, styleable/spannable text, or editable text * * @see #setText(int) * @see #setText(CharSequence) * @see android.widget.TextView.BufferType * @see #setSpannableFactory(Spannable.Factory) * @see #setEditableFactory(Editable.Factory) * * @attr ref android.R.styleable#TextView_text * @attr ref android.R.styleable#TextView_bufferType */ public final void setText(@StringRes int resid, BufferType type) { setText(getContext().getResources().getText(resid), type); } Loading Loading @@ -5110,7 +5200,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * Set the extra input data of the text, which is the * {@link EditorInfo#extras TextBoxAttribute.extras} * Bundle that will be filled in when creating an input connection. The * given integer is the resource ID of an XML resource holding an * given integer is the resource identifier of an XML resource holding an * {@link android.R.styleable#InputExtras <input-extras>} XML tree. * * @see #getInputExtras(boolean) Loading Loading @@ -8832,8 +8922,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } /** * Type of the text buffer that defines the characteristics of the text such as static, * styleable, or editable. */ public enum BufferType { NORMAL, SPANNABLE, EDITABLE, NORMAL, SPANNABLE, EDITABLE } /** Loading