Page Summary
-
The
Selectionclass provides utility methods for manipulating cursors and selections within text. -
It allows you to set, get, extend, and remove selections, as well as move the cursor within a
Spannabletext object. -
SELECTION_STARTandSELECTION_ENDrepresent the boundaries of a text selection. -
A cursor is simply a selection where the start and end points are the same.
-
You can select all text within a
Spannableusing theselectAllmethod.
Utility class for manipulating cursors and selections in CharSequences. A cursor is a selection where the start and end are at the same offset.
Field Summary
| public static final Object | SELECTION_END | |
| public static final Object | SELECTION_START |
Public Method Summary
| final static void | |
| final static int |
getSelectionEnd(CharSequence text)
Return the offset of the selection edge or cursor, or -1 if
there is no selection or cursor.
|
| final static int |
getSelectionStart(CharSequence text)
Return the offset of the selection anchor or cursor, or -1 if
there is no selection or cursor.
|
| final static void | |
| final static void | |
| static void |
setSelection(Spannable text, int start, int stop)
Set the selection anchor to
start and the selection edge
to stop. |
| final static void |
Inherited Method Summary
Fields
public static final Object SELECTION_END
public static final Object SELECTION_START
Public Methods
public static final void extendSelection (Spannable text, int index)
Move the selection edge to offset index.
Parameters
| text | |
|---|---|
| index |
public static final int getSelectionEnd (CharSequence text)
Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor.
Parameters
| text |
|---|
public static final int getSelectionStart (CharSequence text)
Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.
Parameters
| text |
|---|
public static final void removeSelection (Spannable text)
Remove the selection or cursor, if any, from the text.
Parameters
| text |
|---|
public static void setSelection (Spannable text, int start, int stop)
Set the selection anchor to start and the selection edge
to stop.
Parameters
| text | |
|---|---|
| start | |
| stop |
public static final void setSelection (Spannable text, int index)
Move the cursor to offset index.
Parameters
| text | |
|---|---|
| index |