Build 1.0_r1(from source)

android.widget
Class TextView

java.lang.Object
  extended by android.view.View
      extended by android.widget.TextView
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, ViewTreeObserver.OnPreDrawListener
Direct Known Subclasses:
Button, CheckedTextView, Chronometer, DigitalClock, EditText

public class TextView
extends View
implements ViewTreeObserver.OnPreDrawListener

Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing.

XML attributes

See TextView Attributes, View Attributes


Nested Class Summary
static class TextView.BufferType
           
static class TextView.SavedState
          User interface state that is stored by TextView for implementing View.onSaveInstanceState().
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
TextView(Context context)
           
TextView(Context context, AttributeSet attrs)
           
TextView(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 void addTextChangedListener(TextWatcher watcher)
          Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.
 void append(CharSequence text)
          Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.
 void append(CharSequence text, int start, int end)
          Convenience method: Append the specified text slice to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.
protected  int computeHorizontalScrollRange()
          Compute the horizontal range that the horizontal scrollbar represents.
 void computeScroll()
          Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary.
protected  int computeVerticalScrollRange()
          Compute the vertical range that the vertical scrollbar represents.
 void debug(int depth)
          Prints information about this view in the log output, with the tag View.VIEW_LOG_TAG.
protected  void drawableStateChanged()
          This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
 int getAutoLinkMask()
          Gets the autolink mask of the text.
 int getBaseline()
          Return the offset of the widget's text baseline from the widget's top boundary.
 int getCompoundDrawablePadding()
          Returns the padding between the compound drawables and the text.
 Drawable[] getCompoundDrawables()
          Returns drawables for the left, top, right, and bottom borders.
 int getCompoundPaddingBottom()
          Returns the bottom padding of the view, plus space for the bottom Drawable if any.
 int getCompoundPaddingLeft()
          Returns the left padding of the view, plus space for the left Drawable if any.
 int getCompoundPaddingRight()
          Returns the right padding of the view, plus space for the right Drawable if any.
 int getCompoundPaddingTop()
          Returns the top padding of the view, plus space for the top Drawable if any.
 int getCurrentHintTextColor()
          Return the current color selected to paint the hint text.
 int getCurrentTextColor()
          Return the current color selected for normal text.
protected  boolean getDefaultEditable()
          Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.
protected  MovementMethod getDefaultMovementMethod()
          Subclasses override this to specify a default movement method.
 TextUtils.TruncateAt getEllipsize()
          Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.
 CharSequence getError()
          Returns the error message that was set to be displayed with setError(java.lang.CharSequence), or null if no error was set or if it the error was cleared by the widget after user input.
 int getExtendedPaddingBottom()
          Returns the extended bottom padding of the view, including both the bottom Drawable if any and any extra space to keep more than maxLines of text from showing.
 int getExtendedPaddingTop()
          Returns the extended top padding of the view, including both the top Drawable if any and any extra space to keep more than maxLines of text from showing.
 InputFilter[] getFilters()
          Returns the current list of input filters.
 void getFocusedRect(Rect r)
          When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method.
 boolean getFreezesText()
          Return whether this text view is including its entire text contents in frozen icicles.
 int getGravity()
          Returns the horizontal and vertical alignment of this TextView.
 CharSequence getHint()
          Returns the hint that is displayed when the text of the TextView is empty.
 ColorStateList getHintTextColors()
          Return the color used to paint the hint text.
 KeyListener getKeyListener()
           
 Layout getLayout()
           
 int getLineBounds(int line, Rect bounds)
          Return the baseline for the specified line (0...getLineCount() - 1) If bounds is not null, return the top, left, right, bottom extents of the specified line in it.
 int getLineCount()
          Return the number of lines of text, or 0 if the internal Layout has not been built.
 int getLineHeight()
           
 boolean getLinksClickable()
          Returns whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(java.lang.CharSequence).
 ColorStateList getLinkTextColors()
          Returns the color used to paint links in the text.
 MovementMethod getMovementMethod()
           
 TextPaint getPaint()
           
 int getPaintFlags()
           
 int getSelectionEnd()
          Convenience for Selection.getSelectionEnd(java.lang.CharSequence).
 int getSelectionStart()
          Convenience for Selection.getSelectionStart(java.lang.CharSequence).
 CharSequence getText()
          Return the text the TextView is displaying.
static int getTextColor(Context context, TypedArray attrs, int def)
          Returns the default color from the TextView_textColor attribute from the AttributeSet, if set, or the default color from the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly.
 ColorStateList getTextColors()
          Return the set of text colors.
static ColorStateList getTextColors(Context context, TypedArray attrs)
          Returns the TextView_textColor attribute from the Resources.StyledAttributes, if set, or the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly.
 float getTextScaleX()
           
 float getTextSize()
           
 int getTotalPaddingBottom()
          Returns the total bottom padding of the view, including the bottom Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any.
 int getTotalPaddingLeft()
          Returns the total left padding of the view, including the left Drawable if any.
 int getTotalPaddingRight()
          Returns the total right padding of the view, including the right Drawable if any.
 int getTotalPaddingTop()
          Returns the total top padding of the view, including the top Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any.
 TransformationMethod getTransformationMethod()
           
 Typeface getTypeface()
           
 URLSpan[] getUrls()
          Returns the list of URLSpans attached to the text (by Linkify or otherwise) if any.
 boolean hasSelection()
          Return true iff there is a selection inside this text view.
 int length()
          Returns the length, in characters, of the text managed by this TextView
protected  void makeNewLayout(int w, int hintWidth, BoringLayout.Metrics boring, BoringLayout.Metrics hintBoring, int ellipsisWidth, boolean bringIntoView)
          The width passed in is now the desired layout width, not the full view width with padding.
protected  void onCreateContextMenu(ContextMenu menu)
          Views should implement this if the view itself is going to add items to the context menu.
protected  void onDetachedFromWindow()
          This is called when the view is detached from a window.
protected  void onDraw(Canvas canvas)
          Implement this to do your drawing.
protected  void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
          Called by the view system when the focus state of this view changes.
 boolean onKeyDown(int keyCode, KeyEvent event)
          Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.
 boolean onKeyShortcut(int keyCode, KeyEvent event)
          Called when an unhandled key shortcut event occurs.
 boolean onKeyUp(int keyCode, KeyEvent event)
          Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released.
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           Measure the view and its content to determine the measured width and the measured height.
 boolean onPreDraw()
          Callback method to be invoked when the view tree is about to be drawn.
 void onRestoreInstanceState(Parcelable state)
          Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.onSaveInstanceState().
 Parcelable onSaveInstanceState()
          Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.
protected  void onTextChanged(CharSequence text, int start, int before, int after)
          This method is called when the text is changed, in case any subclasses would like to know.
 boolean onTouchEvent(MotionEvent event)
          Implement this method to handle touch screen motion events.
 boolean onTrackballEvent(MotionEvent event)
          Implement this method to handle trackball motion events.
 void onWindowFocusChanged(boolean hasWindowFocus)
          Called when the window containing this view gains or loses focus.
 boolean performLongClick()
          Call this view's OnLongClickListener, if it is defined.
 void removeTextChangedListener(TextWatcher watcher)
          Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.
 void setAutoLinkMask(int mask)
          Sets the autolink mask of the text.
 void setCompoundDrawablePadding(int pad)
          Sets the size of the padding between the compound drawables and the text.
 void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
          Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
 void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
          Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
 void setCursorVisible(boolean visible)
          Set whether the cursor is visible.
 void setEditableFactory(Editable.Factory factory)
          Sets the Factory used to create new Editables.
 void setEllipsize(TextUtils.TruncateAt where)
          Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle.
 void setEms(int ems)
          Makes the TextView exactly this many ems wide
 void setError(CharSequence error)
          Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus.
 void setError(CharSequence error, Drawable icon)
          Sets the right-hand compound drawable of the TextView to the specified icon and sets an error message that will be displayed in a popup when the TextView has focus.
 void setFilters(InputFilter[] filters)
          Sets the list of input filters that will be used if the buffer is Editable.
protected  boolean setFrame(int l, int t, int r, int b)
          Assign a size and position to this view.
 void setFreezesText(boolean freezesText)
          Control whether this text view saves its entire text contents when freezing to an icicle, in addition to dynamic state such as cursor position.
 void setGravity(int gravity)
          Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself.
 void setHeight(int pixels)
          Makes the TextView exactly this many pixels tall.
 void setHighlightColor(int color)
          Sets the color used to display the selection highlight.
 void setHint(CharSequence hint)
          Sets the text to be displayed when the text of the TextView is empty.
 void setHint(int resid)
          Sets the text to be displayed when the text of the TextView is empty, from a resource.
 void setHintTextColor(ColorStateList colors)
          Sets the color of the hint text.
 void setHintTextColor(int color)
          Sets the color of the hint text.
 void setHorizontallyScrolling(boolean whether)
          Sets whether the text should be allowed to be wider than the View is.
 void setIncludeFontPadding(boolean includepad)
          Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.
 void setKeyListener(KeyListener input)
          Sets the key listener to be used with this TextView.
 void setLines(int lines)
          Makes the TextView exactly this many lines tall
 void setLineSpacing(float add, float mult)
          Sets line spacing for this TextView.
 void setLinksClickable(boolean whether)
          Sets whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(java.lang.CharSequence).
 void setLinkTextColor(ColorStateList colors)
          Sets the color of links in the text.
 void setLinkTextColor(int color)
          Sets the color of links in the text.
 void setMaxEms(int maxems)
          Makes the TextView at most this many ems wide
 void setMaxHeight(int maxHeight)
          Makes the TextView at most this many pixels tall
 void setMaxLines(int maxlines)
          Makes the TextView at most this many lines tall
 void setMaxWidth(int maxpixels)
          Makes the TextView at most this many pixels wide
 void setMinEms(int minems)
          Makes the TextView at least this many ems wide
 void setMinHeight(int minHeight)
          Makes the TextView at least this many pixels tall
 void setMinLines(int minlines)
          Makes the TextView at least this many lines tall
 void setMinWidth(int minpixels)
          Makes the TextView at least this many pixels wide
 void setMovementMethod(MovementMethod movement)
          Sets the movement method (arrow key handler) to be used for this TextView.
 void setPadding(int left, int top, int right, int bottom)
          Sets the padding.
 void setPaintFlags(int flags)
          Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.
 void setScroller(Scroller s)
           
 void setSelectAllOnFocus(boolean selectAllOnFocus)
          Set the TextView so that when it takes focus, all the text is selected.
 void setShadowLayer(float radius, float dx, float dy, int color)
          Gives the text a shadow of the specified radius and color, the specified distance from its normal position.
 void setSingleLine()
          Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.
 void setSingleLine(boolean singleLine)
          If true, sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.
 void setSpannableFactory(Spannable.Factory factory)
          Sets the Factory used to create new Spannables.
 void setText(char[] text, int start, int len)
          Sets the TextView to display the specified slice of the specified char array.
 void setText(CharSequence text)
          Sets the string value of the TextView.
 void setText(CharSequence text, TextView.BufferType type)
          Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
 void setText(int resid)
           
 void setText(int resid, TextView.BufferType type)
           
 void setTextAppearance(Context context, int resid)
          Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
 void setTextColor(ColorStateList colors)
          Sets the text color.
 void setTextColor(int color)
          Sets the text color for all the states (normal, selected, focused) to be this color.
 void setTextKeepState(CharSequence text)
          Like setText(CharSequence), except that the cursor position (if any) is retained in the new text.
 void setTextKeepState(CharSequence text, TextView.BufferType type)
          Like setText(CharSequence, android.widget.TextView.BufferType), except that the cursor position (if any) is retained in the new text.
 void setTextScaleX(float size)
          Sets the extent by which text should be stretched horizontally.
 void setTextSize(float size)
          Set the default text size to the given value, interpreted as "scaled pixel" units.
 void setTextSize(int unit, float size)
          Set the default text size to a given unit and value.
 void setTransformationMethod(TransformationMethod method)
          Sets the transformation that is applied to the text that this TextView is displaying.
 void setTypeface(Typeface tf)
          Sets the typeface and style in which the text should be displayed.
 void setTypeface(Typeface tf, int style)
          Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.
 void setWidth(int pixels)
          Makes the TextView exactly this many pixels wide.
 
Methods inherited from class android.view.View
addFocusables, addTouchables, applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, clearFocus, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeVerticalScrollExtent, computeVerticalScrollOffset, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchDraw, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, draw, finalize, findFocus, findViewById, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitSystemWindows, focusSearch, forceLayout, gatherTransparentRegion, getAnimation, getApplicationWindowToken, getBackground, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasFocus, hasFocusable, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onAttachedToWindow, onCreateDrawableState, onFinishInflate, onKeyMultiple, onLayout, onScrollChanged, onSetAlpha, onSizeChanged, onWindowVisibilityChanged, performClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextView

public TextView(Context context)

TextView

public TextView(Context context,
                AttributeSet attrs)

TextView

public TextView(Context context,
                AttributeSet attrs,
                int defStyle)
Method Detail

setTypeface

public void setTypeface(Typeface tf,
                        int style)
Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.


getDefaultEditable

protected boolean getDefaultEditable()
Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.


getDefaultMovementMethod

protected MovementMethod getDefaultMovementMethod()
Subclasses override this to specify a default movement method.


getText

public CharSequence getText()
Return the text the TextView is displaying. If setText() was called with an argument of BufferType.SPANNABLE or BufferType.EDITABLE, you can cast the return value from this method to Spannable or Editable, respectively.


length

public int length()
Returns the length, in characters, of the text managed by this TextView


getLineHeight

public int getLineHeight()
Returns:
the height of one standard line in pixels. Note that markup within the text can cause individual lines to be taller or shorter than this height, and the layout may contain additional first- or last-line padding.

getLayout

public final Layout getLayout()
Returns:
the Layout that is currently being used to display the text. This can be null if the text or width has recently changes.

getKeyListener

public final KeyListener getKeyListener()
Returns:
the current key listener for this TextView. This will frequently be null for non-EditText TextViews.

setKeyListener

public void setKeyListener(KeyListener input)
Sets the key listener to be used with this TextView. This can be null to disallow user input.

Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call View.setFocusable(boolean) again after calling this to get the focusability back the way you want it.


getMovementMethod

public final MovementMethod getMovementMethod()
Returns:
the movement method being used for this TextView. This will frequently be null for non-EditText TextViews.

setMovementMethod

public final void setMovementMethod(MovementMethod movement)
Sets the movement method (arrow key handler) to be used for this TextView. This can be null to disallow using the arrow keys to move the cursor or scroll the view.

Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call View.setFocusable(boolean) again after calling this to get the focusability back the way you want it.


getTransformationMethod

public final TransformationMethod getTransformationMethod()
Returns:
the current transformation method for this TextView. This will frequently be null except for single-line and password fields.

setTransformationMethod

public final void setTransformationMethod(TransformationMethod method)
Sets the transformation that is applied to the text that this TextView is displaying.


getCompoundPaddingTop

public int getCompoundPaddingTop()
Returns the top padding of the view, plus space for the top Drawable if any.


getCompoundPaddingBottom

public int getCompoundPaddingBottom()
Returns the bottom padding of the view, plus space for the bottom Drawable if any.


getCompoundPaddingLeft

public int getCompoundPaddingLeft()
Returns the left padding of the view, plus space for the left Drawable if any.


getCompoundPaddingRight

public int getCompoundPaddingRight()
Returns the right padding of the view, plus space for the right Drawable if any.


getExtendedPaddingTop

public int getExtendedPaddingTop()
Returns the extended top padding of the view, including both the top Drawable if any and any extra space to keep more than maxLines of text from showing. It is only valid to call this after measuring.


getExtendedPaddingBottom

public int getExtendedPaddingBottom()
Returns the extended bottom padding of the view, including both the bottom Drawable if any and any extra space to keep more than maxLines of text from showing. It is only valid to call this after measuring.


getTotalPaddingLeft

public int getTotalPaddingLeft()
Returns the total left padding of the view, including the left Drawable if any.


getTotalPaddingRight

public int getTotalPaddingRight()
Returns the total right padding of the view, including the right Drawable if any.


getTotalPaddingTop

public int getTotalPaddingTop()
Returns the total top padding of the view, including the top Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any.


getTotalPaddingBottom

public int getTotalPaddingBottom()
Returns the total bottom padding of the view, including the bottom Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any.


setCompoundDrawables

public void setCompoundDrawables(Drawable left,
                                 Drawable top,
                                 Drawable right,
                                 Drawable bottom)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had Drawable.setBounds(int, int, int, int) called.


setCompoundDrawablesWithIntrinsicBounds

public void setCompoundDrawablesWithIntrinsicBounds(Drawable left,
                                                    Drawable top,
                                                    Drawable right,
                                                    Drawable bottom)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.


getCompoundDrawables

public Drawable[] getCompoundDrawables()
Returns drawables for the left, top, right, and bottom borders.


setCompoundDrawablePadding

public void setCompoundDrawablePadding(int pad)
Sets the size of the padding between the compound drawables and the text.


getCompoundDrawablePadding

public int getCompoundDrawablePadding()
Returns the padding between the compound drawables and the text.


setPadding

public void setPadding(int left,
                       int top,
                       int right,
                       int bottom)
Description copied from class: View
Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from View.getPaddingLeft(), View.getPaddingTop(), View.getPaddingRight() and View.getPaddingBottom() may be different from the values set in this call.

Overrides:
setPadding in class View
Parameters:
left - the left padding in pixels
top - the top padding in pixels
right - the right padding in pixels
bottom - the bottom padding in pixels

getAutoLinkMask

public final int getAutoLinkMask()
Gets the autolink mask of the text. See Linkify.ALL and peers for possible values.


setTextAppearance

public void setTextAppearance(Context context,
                              int resid)
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.


getTextSize

public float getTextSize()
Returns:
the size (in pixels) of the default text size in this TextView.

setTextSize

public void setTextSize(float size)
Set the default text size to the given value, interpreted as "scaled pixel" units. This size is adjusted based on the current density and user font size preference.

Parameters:
size - The scaled pixel size.

setTextSize

public void setTextSize(int unit,
                        float size)
Set the default text size to a given unit and value. See TypedValue for the possible dimension units.

Parameters:
unit - The desired dimension unit.
size - The desired size in the given units.

getTextScaleX

public float getTextScaleX()
Returns:
the extent by which text is currently being stretched horizontally. This will usually be 1.

setTextScaleX

public void setTextScaleX(float size)
Sets the extent by which text should be stretched horizontally.


setTypeface

public void setTypeface(Typeface tf)
Sets the typeface and style in which the text should be displayed. Note that not all Typeface families actually have bold and italic variants, so you may need to use setTypeface(Typeface, int) to get the appearance that you actually want.


getTypeface

public Typeface getTypeface()
Returns:
the current typeface and style in which the text is being displayed.

setTextColor

public void setTextColor(int color)
Sets the text color for all the states (normal, selected, focused) to be this color.


setTextColor

public void setTextColor(ColorStateList colors)
Sets the text color.


getTextColors

public final ColorStateList getTextColors()
Return the set of text colors.

Returns:
Returns the set of text colors.

getCurrentTextColor

public final int getCurrentTextColor()

Return the current color selected for normal text.

Returns:
Returns the current text color.

setHighlightColor

public void setHighlightColor(int color)
Sets the color used to display the selection highlight.


setShadowLayer

public void setShadowLayer(float radius,
                           float dx,
                           float dy,
                           int color)
Gives the text a shadow of the specified radius and color, the specified distance from its normal position.


getPaint

public TextPaint getPaint()
Returns:
the base paint used for the text. Please use this only to consult the Paint's properties and not to change them.

setAutoLinkMask

public final void setAutoLinkMask(int mask)
Sets the autolink mask of the text. See Linkify.ALL and peers for possible values.


setLinksClickable

public final void setLinksClickable(boolean whether)
Sets whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(java.lang.CharSequence). The default is true.


getLinksClickable

public final boolean getLinksClickable()
Returns whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(java.lang.CharSequence). The default is true.


getUrls

public URLSpan[] getUrls()
Returns the list of URLSpans attached to the text (by Linkify or otherwise) if any. You can call URLSpan.getURL() on them to find where they link to or use Spanned.getSpanStart(java.lang.Object) and Spanned.getSpanEnd(java.lang.Object) to find the region of the text they are attached to.


setHintTextColor

public final void setHintTextColor(int color)
Sets the color of the hint text.


setHintTextColor

public final void setHintTextColor(ColorStateList colors)
Sets the color of the hint text.


getHintTextColors

public final ColorStateList getHintTextColors()

Return the color used to paint the hint text.

Returns:
Returns the list of hint text colors.

getCurrentHintTextColor

public final int getCurrentHintTextColor()

Return the current color selected to paint the hint text.

Returns:
Returns the current hint text color.

setLinkTextColor

public final void setLinkTextColor(int color)
Sets the color of links in the text.


setLinkTextColor

public final void setLinkTextColor(ColorStateList colors)
Sets the color of links in the text.


getLinkTextColors

public final ColorStateList getLinkTextColors()

Returns the color used to paint links in the text.

Returns:
Returns the list of link text colors.

setGravity

public void setGravity(int gravity)
Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself.

See Also:
Gravity

getGravity

public int getGravity()
Returns the horizontal and vertical alignment of this TextView.

See Also:
Gravity

getPaintFlags

public int getPaintFlags()
Returns:
the flags on the Paint being used to display the text.
See Also:
Paint.getFlags()

setPaintFlags

public void setPaintFlags(int flags)
Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.

See Also:
Paint.setFlags(int)

setHorizontallyScrolling

public void setHorizontallyScrolling(boolean whether)
Sets whether the text should be allowed to be wider than the View is. If false, it will be wrapped to the width of the View.


setMinLines

public void setMinLines(int minlines)
Makes the TextView at least this many lines tall


setMinHeight

public void setMinHeight(int minHeight)
Makes the TextView at least this many pixels tall


setMaxLines

public void setMaxLines(int maxlines)
Makes the TextView at most this many lines tall


setMaxHeight

public void setMaxHeight(int maxHeight)
Makes the TextView at most this many pixels tall


setLines

public void setLines(int lines)
Makes the TextView exactly this many lines tall


setHeight

public void setHeight(int pixels)
Makes the TextView exactly this many pixels tall. You could do the same thing by specifying this number in the LayoutParams.


setMinEms

public void setMinEms(int minems)
Makes the TextView at least this many ems wide


setMinWidth

public void setMinWidth(int minpixels)
Makes the TextView at least this many pixels wide


setMaxEms

public void setMaxEms(int maxems)
Makes the TextView at most this many ems wide


setMaxWidth

public void setMaxWidth(int maxpixels)
Makes the TextView at most this many pixels wide


setEms

public void setEms(int ems)
Makes the TextView exactly this many ems wide


setWidth

public void setWidth(int pixels)
Makes the TextView exactly this many pixels wide. You could do the same thing by specifying this number in the LayoutParams.


setLineSpacing

public void setLineSpacing(float add,
                           float mult)
Sets line spacing for this TextView. Each line will have its height multiplied by mult and have add added to it.


append

public final void append(CharSequence text)
Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.


append

public void append(CharSequence text,
                   int start,
                   int end)
Convenience method: Append the specified text slice to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.


drawableStateChanged

protected void drawableStateChanged()
Description copied from class: View
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

Be sure to call through to the superclass when overriding this function.

Overrides:
drawableStateChanged in class View
See Also:
Drawable.setState(int[])

onSaveInstanceState

public Parcelable onSaveInstanceState()
Description copied from class: View
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.

Overrides:
onSaveInstanceState in class View
Returns:
Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save. The default implementation returns null.
See Also:
View.onRestoreInstanceState(android.os.Parcelable), View.saveHierarchyState(android.util.SparseArray), View.dispatchSaveInstanceState(android.util.SparseArray), View.setSaveEnabled(boolean)

onRestoreInstanceState

public void onRestoreInstanceState(Parcelable state)
Description copied from class: View
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.onSaveInstanceState(). This function will never be called with a null state.

Overrides:
onRestoreInstanceState in class View
Parameters:
state - The frozen state that had previously been returned by View.onSaveInstanceState().
See Also:
View.onSaveInstanceState(), View.restoreHierarchyState(android.util.SparseArray), View.dispatchRestoreInstanceState(android.util.SparseArray)

setFreezesText

public void setFreezesText(boolean freezesText)
Control whether this text view saves its entire text contents when freezing to an icicle, in addition to dynamic state such as cursor position. By default this is false, not saving the text. Set to true if the text in the text view is not being saved somewhere else in persistent storage (such as in a content provider) so that if the view is later thawed the user will not lose their data.

Parameters:
freezesText - Controls whether a frozen icicle should include the entire text data: true to include it, false to not.

getFreezesText

public boolean getFreezesText()
Return whether this text view is including its entire text contents in frozen icicles.

Returns:
Returns true if text is included, false if it isn't.
See Also:
setFreezesText(boolean)

setEditableFactory

public final void setEditableFactory(Editable.Factory factory)
Sets the Factory used to create new Editables.


setSpannableFactory

public final void setSpannableFactory(Spannable.Factory factory)
Sets the Factory used to create new Spannables.


setText

public final void setText(CharSequence text)
Sets the string value of the TextView. TextView does not 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 SpannableString, or see String Resources for an example of setting formatted text in the XML resource file.


setTextKeepState

public final void setTextKeepState(CharSequence text)
Like setText(CharSequence), except that the cursor position (if any) is retained in the new text.

Parameters:
text - The new text to place in the text view.
See Also:
setText(CharSequence)

setText

public void setText(CharSequence text,
                    TextView.BufferType type)
Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.


setText

public final void setText(char[] text,
                          int start,
                          int len)
Sets the TextView to display the specified slice of the specified char array. You must promise that you will not change the contents 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.


setTextKeepState

public final void setTextKeepState(CharSequence text,
                                   TextView.BufferType type)
Like setText(CharSequence, android.widget.TextView.BufferType), except that the cursor position (if any) is retained in the new text.

See Also:
setText(CharSequence, android.widget.TextView.BufferType)

setText

public final void setText(int resid)

setText

public final void setText(int resid,
                          TextView.BufferType type)

setHint

public final void setHint(CharSequence hint)
Sets the text to be displayed when the text of the TextView is empty. Null means to use the normal empty text. The hint does not currently participate in determining the size of the view.


setHint

public final void setHint(int resid)
Sets the text to be displayed when the text of the TextView is empty, from a resource.


getHint

public CharSequence getHint()
Returns the hint that is displayed when the text of the TextView is empty.


getError

public CharSequence getError()
Returns the error message that was set to be displayed with setError(java.lang.CharSequence), or null if no error was set or if it the error was cleared by the widget after user input.


setError

public void setError(CharSequence error)
Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus. The icon and error message will be reset to null when any key events cause changes to the TextView's text. If the error is null, the error message and icon will be cleared.


setError

public void setError(CharSequence error,
                     Drawable icon)
Sets the right-hand compound drawable of the TextView to the specified icon and sets an error message that will be displayed in a popup when the TextView has focus. The icon and error message will be reset to null when any key events cause changes to the TextView's text. The drawable must already have had Drawable.setBounds(int, int, int, int) set on it. If the error is null, the error message will be cleared (and you should provide a null icon as well).


setFrame

protected boolean setFrame(int l,
                           int t,
                           int r,
                           int b)
Description copied from class: View
Assign a size and position to this view. This is called from layout.

Overrides:
setFrame in class View
Parameters:
l - Left position, relative to parent
t - Top position, relative to parent
r - Right position, relative to parent
b - Bottom position, relative to parent
Returns:
true if the new size and position are different than the previous ones

setFilters

public void setFilters(InputFilter[] filters)
Sets the list of input filters that will be used if the buffer is Editable. Has no effect otherwise.


getFilters

public InputFilter[] getFilters()
Returns the current list of input filters.


onPreDraw

public boolean onPreDraw()
Callback method to be invoked when the view tree is about to be drawn. At this point, all views in the tree have been measured and given a frame. Clients can use this to adjust their scroll bounds or even to request a new layout before drawing occurs.

Specified by:
onPreDraw in interface ViewTreeObserver.OnPreDrawListener
Returns:
Return true to proceed with the current drawing pass, or false to cancel.
See Also:
View.onMeasure(int, int), View.onLayout(boolean, int, int, int, int), View.onDraw(android.graphics.Canvas)

onDetachedFromWindow

protected void onDetachedFromWindow()
Description copied from class: View
This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

Overrides:
onDetachedFromWindow in class View
See Also:
View.onAttachedToWindow()

onDraw

protected void onDraw(Canvas canvas)
Description copied from class: View
Implement this to do your drawing.

Overrides:
onDraw in class View
Parameters:
canvas - the canvas on which the background will be drawn

getFocusedRect

public void getFocusedRect(Rect r)
Description copied from class: View
When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method. By default, the rectange is the View.getDrawingRect(android.graphics.Rect))of the view. However, if your view maintains some idea of internal selection, such as a cursor, or a selected row or column, you should override this method and fill in a more specific rectangle.

Overrides:
getFocusedRect in class View
Parameters:
r - The rectangle to fill in, in this view's coordinates.

getLineCount

public int getLineCount()
Return the number of lines of text, or 0 if the internal Layout has not been built.


getLineBounds

public int getLineBounds(int line,
                         Rect bounds)
Return the baseline for the specified line (0...getLineCount() - 1) If bounds is not null, return the top, left, right, bottom extents of the specified line in it. If the internal Layout has not been built, return 0 and set bounds to (0, 0, 0, 0)

Parameters:
line - which line to examine (0..getLineCount() - 1)
bounds - Optional. If not null, it returns the extent of the line
Returns:
the Y-coordinate of the baseline

getBaseline

public int getBaseline()
Description copied from class: View

Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.

Overrides:
getBaseline in class View
Returns:
the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Description copied from class: View
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

Specified by:
onKeyDown in interface KeyEvent.Callback
Overrides:
onKeyDown in class View
Parameters:
keyCode - A key code that represents the button pressed, from KeyEvent.
event - The KeyEvent object that defines the button action.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyUp

public boolean onKeyUp(int keyCode,
                       KeyEvent event)
Description copied from class: View
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released.

Specified by:
onKeyUp in interface KeyEvent.Callback
Overrides:
onKeyUp in class View
Parameters:
keyCode - A key code that represents the button pressed, from KeyEvent.
event - The KeyEvent object that defines the button action.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

makeNewLayout

protected void makeNewLayout(int w,
                             int hintWidth,
                             BoringLayout.Metrics boring,
                             BoringLayout.Metrics hintBoring,
                             int ellipsisWidth,
                             boolean bringIntoView)
The width passed in is now the desired layout width, not the full view width with padding.


setIncludeFontPadding

public void setIncludeFontPadding(boolean includepad)
Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent. The default is true.


onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Description copied from class: View

Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling the superclass' View.onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override View.onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (View.getSuggestedMinimumHeight() and View.getSuggestedMinimumWidth()).

Overrides:
onMeasure in class View
Parameters:
widthMeasureSpec - horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec - vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
See Also:
View.getMeasuredWidth(), View.getMeasuredHeight(), View.setMeasuredDimension(int, int), View.getSuggestedMinimumHeight(), View.getSuggestedMinimumWidth(), View.MeasureSpec.getMode(int), View.MeasureSpec.getSize(int)

computeScroll

public void computeScroll()
Description copied from class: View
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a Scroller object.

Overrides:
computeScroll in class View

debug

public void debug(int depth)
Description copied from class: View
Prints information about this view in the log output, with the tag View.VIEW_LOG_TAG. Each line in the output is preceded with an indentation defined by the depth.

Overrides:
debug in class View
Parameters:
depth - the indentation level

getSelectionStart

public int getSelectionStart()
Convenience for Selection.getSelectionStart(java.lang.CharSequence).


getSelectionEnd

public int getSelectionEnd()
Convenience for Selection.getSelectionEnd(java.lang.CharSequence).


hasSelection

public boolean hasSelection()
Return true iff there is a selection inside this text view.


setSingleLine

public void setSingleLine()
Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.


setSingleLine

public void setSingleLine(boolean singleLine)
If true, sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions. Note that calling this with false restores default conditions, not necessarily those that were in effect prior to calling it with true.


setEllipsize

public void setEllipsize(TextUtils.TruncateAt where)
Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle. You may also want to setSingleLine() or setHorizontallyScrolling(boolean) to constrain the text toa single line. Use null to turn off ellipsizing.


getEllipsize

public TextUtils.TruncateAt getEllipsize()
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.


setSelectAllOnFocus

public void setSelectAllOnFocus(boolean selectAllOnFocus)
Set the TextView so that when it takes focus, all the text is selected.


setCursorVisible

public void setCursorVisible(boolean visible)
Set whether the cursor is visible. The default is true.


onTextChanged

protected void onTextChanged(CharSequence text,
                             int start,
                             int before,
                             int after)
This method is called when the text is changed, in case any subclasses would like to know.

Parameters:
text - The text the TextView is displaying.
start - The offset of the start of the range of the text that was modified.
before - The offset of the former end of the range of the text that was modified. If text was simply inserted, this will be the same as start. If text was replaced with new text or deleted, the length of the old text was before-start.
after - The offset of the end of the range of the text that was modified. If text was simply deleted, this will be the same as start. If text was replaced with new text or inserted, the length of the new text is after-start.

addTextChangedListener

public void addTextChangedListener(TextWatcher watcher)
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.


removeTextChangedListener

public void removeTextChangedListener(TextWatcher watcher)
Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.


onFocusChanged

protected void onFocusChanged(boolean focused,
                              int direction,
                              Rect previouslyFocusedRect)
Description copied from class: View
Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from.

Overrides:
onFocusChanged in class View
Parameters:
focused - True if the View has focus; false otherwise.
direction - The direction focus has moved when requestFocus() is called to give this view focus. Values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. It may not always apply, in which case use the default.
previouslyFocusedRect - The rectangle, in this view's coordinate system, of the previously focused view. If applicable, this will be passed in as finer grained information about where the focus is coming from (in addition to direction). Will be null otherwise.

onWindowFocusChanged

public void onWindowFocusChanged(boolean hasWindowFocus)
Description copied from class: View
Called when the window containing this view gains or loses focus. Note that this is separate from view focus: to receive key events, both your view and its window must have focus. If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.

Overrides:
onWindowFocusChanged in class View
Parameters:
hasWindowFocus - True if the window containing this view now has focus, false otherwise.

onTouchEvent

public boolean onTouchEvent(MotionEvent event)
Description copied from class: View
Implement this method to handle touch screen motion events.

Overrides:
onTouchEvent in class View
Parameters:
event - The motion event.
Returns:
True if the event was handled, false otherwise.

onTrackballEvent

public boolean onTrackballEvent(MotionEvent event)
Description copied from class: View
Implement this method to handle trackball motion events. The relative movement of the trackball since the last event can be retrieve with MotionEvent.getX() and MotionEvent.getY(). These are normalized so that a movement of 1 corresponds to the user pressing one DPAD key (so they will often be fractional values, representing the more fine-grained movement information available from a trackball).

Overrides:
onTrackballEvent in class View
Parameters:
event - The motion event.
Returns:
True if the event was handled, false otherwise.

setScroller

public void setScroller(Scroller s)

computeHorizontalScrollRange

protected int computeHorizontalScrollRange()
Description copied from class: View

Compute the horizontal range that the horizontal scrollbar represents.

The range is expressed in arbitrary units that must be the same as the units used by View.computeHorizontalScrollExtent() and View.computeHorizontalScrollOffset().

The default range is the drawing width of this view.

Overrides:
computeHorizontalScrollRange in class View
Returns:
the total horizontal range represented by the horizontal scrollbar
See Also:
View.computeHorizontalScrollExtent(), View.computeHorizontalScrollOffset(), ScrollBarDrawable

computeVerticalScrollRange

protected int computeVerticalScrollRange()
Description copied from class: View

Compute the vertical range that the vertical scrollbar represents.

The range is expressed in arbitrary units that must be the same as the units used by View.computeVerticalScrollExtent() and View.computeVerticalScrollOffset().

Overrides:
computeVerticalScrollRange in class View
Returns:
the total vertical range represented by the vertical scrollbar

The default range is the drawing height of this view.

See Also:
View.computeVerticalScrollExtent(), View.computeVerticalScrollOffset(), ScrollBarDrawable

getTextColors

public static ColorStateList getTextColors(Context context,
                                           TypedArray attrs)
Returns the TextView_textColor attribute from the Resources.StyledAttributes, if set, or the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly.


getTextColor

public static int getTextColor(Context context,
                               TypedArray attrs,
                               int def)
Returns the default color from the TextView_textColor attribute from the AttributeSet, if set, or the default color from the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly.


onKeyShortcut

public boolean onKeyShortcut(int keyCode,
                             KeyEvent event)
Description copied from class: View
Called when an unhandled key shortcut event occurs.

Overrides:
onKeyShortcut in class View
Parameters:
keyCode - The value in event.getKeyCode().
event - Description of the key event.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onCreateContextMenu

protected void onCreateContextMenu(ContextMenu menu)
Description copied from class: View
Views should implement this if the view itself is going to add items to the context menu.

Overrides:
onCreateContextMenu in class View
Parameters:
menu - the context menu to populate

performLongClick

public boolean performLongClick()
Description copied from class: View
Call this view's OnLongClickListener, if it is defined. Invokes the context menu if the OnLongClickListener did not consume the event.

Overrides:
performLongClick in class View
Returns:
True there was an assigned OnLongClickListener that was called, false otherwise is returned.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature