Selection

public class Selection extends Object

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
extendSelection(Spannable text, int index)
Move the selection edge to offset index.
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
removeSelection(Spannable text)
Remove the selection or cursor, if any, from the text.
final static void
selectAll(Spannable text)
Select the entire text.
static void
setSelection(Spannable text, int start, int stop)
Set the selection anchor to start and the selection edge to stop.
final static void
setSelection(Spannable text, int index)
Move the cursor to offset index.

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 final void selectAll (Spannable text)

Select the entire 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