Class EditText
- All Implemented Interfaces:
Drawable.Callback
,ViewTreeObserver.OnPreDrawListener
You can receive callbacks as a user changes text by
adding a TextWatcher
to the edit text.
This is useful when you want to add auto-save functionality as changes are made,
or validate the format of user input, for example.
You add a text watcher using the TextView.addTextChangedListener(icyllis.modernui.text.TextWatcher)
method.
To create an EditText
(an editable TextView):
EditText editText = new EditText();
To make it a single line EditText (a text field):
editText.setSingleLine();To make it a password EditText:
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.widget.TextView
TextView.BufferType
Nested classes/interfaces inherited from class icyllis.modernui.view.View
View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
-
Field Summary
Fields inherited from class icyllis.modernui.widget.TextView
UNKNOWN_BORING
Fields inherited from class icyllis.modernui.view.View
ALPHA, BOTTOM, 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, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, LEFT, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mScrollX, mScrollY, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, 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_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, RIGHT, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TOP, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
extendSelection
(int index) Convenience forSelection.extendSelection(Spannable, int)
.getText()
Return the text that TextView is displaying.void
Convenience forSelection.selectAll(icyllis.modernui.text.Spannable)
.void
setEllipsize
(TextUtils.TruncateAt ellipsis) Causes words in the text that are longer than the view's width to be ellipsized instead of broken in the middle.void
setSelection
(int index) Convenience forSelection.setSelection(Spannable, int)
.void
setSelection
(int start, int stop) Convenience forSelection.setSelection(Spannable, int, int)
.void
setText
(CharSequence text, TextView.BufferType type) Sets the text to be displayed and theTextView.BufferType
.Methods inherited from class icyllis.modernui.widget.TextView
addTextChangedListener, bringPointIntoView, cancelLongPress, computeHorizontalScrollRange, computeVerticalScrollExtent, computeVerticalScrollRange, didTouchFocusSelect, drawableStateChanged, getAutoLinkMask, getBaseline, getCompoundDrawablePadding, getCompoundDrawables, getCompoundDrawablesRelative, getCompoundPaddingBottom, getCompoundPaddingEnd, getCompoundPaddingLeft, getCompoundPaddingRight, getCompoundPaddingStart, getCompoundPaddingTop, getCurrentHintTextColor, getCurrentTextColor, getEditableText, getEllipsize, getExtendedPaddingBottom, getExtendedPaddingTop, getFilters, getFirstBaselineToTopHeight, getFocusedRect, getGravity, getHighlightColor, getHint, getHintTextColors, getHorizontalOffsetForDrawables, getIncludeFontPadding, getLastBaselineToBottomHeight, getLayout, getLineBounds, getLineBreakStyle, getLineBreakWordStyle, getLineCount, getLineHeight, getLinksClickable, getLinkTextColors, getMaxHeight, getMaxLines, getMaxWidth, getMinHeight, getMinLines, getMinWidth, getMovementMethod, getOffsetForPosition, getPaint, getSelectionEnd, getSelectionStart, getTextColors, getTextDirectionHeuristic, getTextLocale, getTextMetricsParams, getTextSize, getTextStyle, getTotalPaddingBottom, getTotalPaddingEnd, getTotalPaddingLeft, getTotalPaddingRight, getTotalPaddingStart, getTotalPaddingTop, getTransformationMethod, getTypeface, getWordIterator, hasSelection, isCursorVisible, isFallbackLineSpacing, isHorizontallyScrollable, isTextSelectable, jumpDrawablesToCurrentState, makeNewLayout, moveCursorToVisibleOffset, nullLayouts, onAttachedToWindow, onCreateContextMenu, onCreateDrawableState, onDetachedFromWindow, onDraw, onFocusChanged, onGenericMotionEvent, onKeyDown, onKeyShortcut, onKeyUp, onLayout, onMeasure, onPreDraw, onResolveDrawables, onResolvePointerIcon, onRtlPropertiesChanged, onTextChanged, onTextContextMenuItem, onTouchEvent, removeTextChangedListener, setAutoLinkMask, setCompoundDrawablePadding, setCompoundDrawables, setCompoundDrawablesRelative, setCompoundDrawablesRelativeWithIntrinsicBounds, setCompoundDrawablesWithIntrinsicBounds, setCursorVisible, setEditableFactory, setEnabled, setFallbackLineSpacing, setFilters, setFirstBaselineToTopHeight, setGravity, setHeight, setHighlightColor, setHint, setHintTextColor, setHintTextColor, setHorizontallyScrolling, setIncludeFontPadding, setLastBaselineToBottomHeight, setLineBreakStyle, setLineBreakWordStyle, setLines, setLinksClickable, setLinkTextColor, setLinkTextColor, setMaxHeight, setMaxLines, setMaxWidth, setMinHeight, setMinLines, setMinWidth, setMovementMethod, setPadding, setPaddingRelative, setSelectAllOnFocus, setSingleLine, setSingleLine, setSpannableFactory, setText, setTextColor, setTextColor, setTextIsSelectable, setTextKeepState, setTextKeepState, setTextLocale, setTextMetricsParams, setTextSize, setTextSize, setTextStyle, setTransformationMethod, setTypeface, setWidth, showContextMenu, useDynamicLayout, verifyDrawable
Methods inherited from class icyllis.modernui.view.View
addFocusables, addFocusables, addKeyboardNavigationClusters, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, awakenScrollBars, awakenScrollBars, callOnClick, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeScroll, computeVerticalScrollOffset, createContextMenu, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchTouchEvent, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, dp, draw, drawableHotspotChanged, findFocus, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewByPredicateTraversal, findViewTraversal, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBottom, getBoundsOnScreen, getBoundsOnScreen, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, handleScrollBarDragging, hasExplicitFocusable, hasFocus, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTransientState, hasTranslationTransientState, hasWindowFocus, internalSetPadding, invalidate, invalidateDrawable, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, layout, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCancelPendingInputEvents, onDragEvent, onDrawForeground, onDrawScrollBars, onFinishTemporaryDetach, onHoverChanged, onHoverEvent, onOverScrolled, onScrollChanged, onSizeChanged, onStartTemporaryDetach, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestFocus, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resetResolvedDrawables, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreDefaultFocus, scheduleDrawable, scrollBy, scrollTo, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setContextClickable, setDuplicateParentStateEnabled, setElevation, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setFocusedInCluster, setForeground, setForegroundGravity, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOverScrollMode, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, willNotDraw
-
Constructor Details
-
EditText
-
-
Method Details
-
getText
Description copied from class:TextView
Return the text that TextView is displaying. IfTextView.setText(CharSequence)
was called with an argument ofBufferType.SPANNABLE
orBufferType.EDITABLE
, you can cast the return value from this method to Spannable or Editable, respectively.The content of the return value should not be modified. If you want a modifiable one, you should make your own copy first.
-
setText
Description copied from class:TextView
Sets the text to be displayed and theTextView.BufferType
. When required, TextView will useSpannable.Factory
to create final or intermediateSpannables
. Likewise, it will useEditable.Factory
to create final or intermediateEditables
.Subclasses overriding this method should ensure that the following post condition holds, in order to guarantee the safety of the view's measurement and layout operations: regardless of the input, after calling #setText both
mText
andmTransformed
will be different fromnull
.- Overrides:
setText
in classTextView
- Parameters:
text
- text to be displayedtype
- aTextView.BufferType
which defines whether the text is stored as a static text, styleable/spannable text, or editable text- See Also:
-
setSelection
public void setSelection(int start, int stop) Convenience forSelection.setSelection(Spannable, int, int)
. -
setSelection
public void setSelection(int index) Convenience forSelection.setSelection(Spannable, int)
. -
selectAll
public void selectAll()Convenience forSelection.selectAll(icyllis.modernui.text.Spannable)
. -
extendSelection
public void extendSelection(int index) Convenience forSelection.extendSelection(Spannable, int)
. -
setEllipsize
Causes words in the text that are longer than the view's width to be ellipsized instead of broken in the middle.TextUtils.TruncateAt#MARQUEE
is not supported.- Overrides:
setEllipsize
in classTextView
- Parameters:
ellipsis
- Type of ellipsis to be applied.- Throws:
IllegalArgumentException
- When the value ofellipsis
parameter isTextUtils.TruncateAt.MARQUEE
.- See Also:
-