Added in API level 1

Selection

open class Selection
kotlin.Any
   ↳ android.text.Selection

Utility class for manipulating cursors and selections in CharSequences. A cursor is a selection where the start and end are at the same offset.

Summary

Public methods
open static Boolean
extendDown(text: Spannable!, layout: Layout!)

Move the selection end to the buffer offset physically below the current selection end.

open static Boolean
extendLeft(text: Spannable!, layout: Layout!)

Move the selection end to the buffer offset physically to the left of the current selection end.

open static Boolean
extendRight(text: Spannable!, layout: Layout!)

Move the selection end to the buffer offset physically to the right of the current selection end.

static Unit
extendSelection(text: Spannable!, index: Int)

Move the selection edge to offset index.

open static Boolean
extendToLeftEdge(text: Spannable!, layout: Layout!)

open static Boolean

Extend the selection to the closest paragraph end offset.

open static Boolean

Extend the selection to the closest paragraph start offset.

open static Boolean
extendToRightEdge(text: Spannable!, layout: Layout!)

open static Boolean
extendUp(text: Spannable!, layout: Layout!)

Move the selection end to the buffer offset physically above the current selection end.

static Int

Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor.

static Int

Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.

open static Boolean
moveDown(text: Spannable!, layout: Layout!)

Move the cursor to the buffer offset physically below the current offset, to the end of the buffer if it is on the bottom line but not at the end, or return false if the cursor is already at the end of the buffer.

open static Boolean
moveLeft(text: Spannable!, layout: Layout!)

Move the cursor to the buffer offset physically to the left of the current offset, or return false if the cursor is already at the left edge of the line and there is not another line to move it to.

open static Boolean
moveRight(text: Spannable!, layout: Layout!)

Move the cursor to the buffer offset physically to the right of the current offset, or return false if the cursor is already at at the right edge of the line and there is not another line to move it to.

open static Boolean
moveToLeftEdge(text: Spannable!, layout: Layout!)

open static Boolean

Move the cursor to the closest paragraph end offset.

open static Boolean

Move the cusrot to the closest paragraph start offset.

open static Boolean
moveToRightEdge(text: Spannable!, layout: Layout!)

open static Boolean
moveUp(text: Spannable!, layout: Layout!)

Move the cursor to the buffer offset physically above the current offset, to the beginning if it is on the top line but not at the start, or return false if the cursor is already on the top line.

static Unit

Remove the selection or cursor, if any, from the text.

static Unit

Select the entire text.

open static Unit
setSelection(text: Spannable!, start: Int, stop: Int)

Set the selection anchor to start and the selection edge to stop.

static Unit
setSelection(text: Spannable!, index: Int)

Move the cursor to offset index.

Properties
static Any!

static Any!

Public methods

extendDown

Added in API level 1
open static fun extendDown(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the selection end to the buffer offset physically below the current selection end.

extendLeft

Added in API level 1
open static fun extendLeft(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the selection end to the buffer offset physically to the left of the current selection end.

extendRight

Added in API level 1
open static fun extendRight(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the selection end to the buffer offset physically to the right of the current selection end.

extendSelection

Added in API level 1
static fun extendSelection(
    text: Spannable!,
    index: Int
): Unit

Move the selection edge to offset index.

extendToLeftEdge

Added in API level 1
open static fun extendToLeftEdge(
    text: Spannable!,
    layout: Layout!
): Boolean

extendToParagraphEnd

Added in API level 34
open static fun extendToParagraphEnd(text: Spannable): Boolean

Extend the selection to the closest paragraph end offset.

Parameters
text Spannable: the spannable text This value cannot be null.
Return
Boolean true if the selection is extended, otherwise false

extendToParagraphStart

Added in API level 34
open static fun extendToParagraphStart(text: Spannable): Boolean

Extend the selection to the closest paragraph start offset.

Parameters
text Spannable: the spannable text This value cannot be null.
Return
Boolean true if the selection is extended, otherwise false

extendToRightEdge

Added in API level 1
open static fun extendToRightEdge(
    text: Spannable!,
    layout: Layout!
): Boolean

extendUp

Added in API level 1
open static fun extendUp(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the selection end to the buffer offset physically above the current selection end.

getSelectionEnd

Added in API level 1
static fun getSelectionEnd(text: CharSequence!): Int

Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor.

getSelectionStart

Added in API level 1
static fun getSelectionStart(text: CharSequence!): Int

Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.

moveDown

Added in API level 1
open static fun moveDown(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the cursor to the buffer offset physically below the current offset, to the end of the buffer if it is on the bottom line but not at the end, or return false if the cursor is already at the end of the buffer.

moveLeft

Added in API level 1
open static fun moveLeft(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the cursor to the buffer offset physically to the left of the current offset, or return false if the cursor is already at the left edge of the line and there is not another line to move it to.

moveRight

Added in API level 1
open static fun moveRight(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the cursor to the buffer offset physically to the right of the current offset, or return false if the cursor is already at at the right edge of the line and there is not another line to move it to.

moveToLeftEdge

Added in API level 1
open static fun moveToLeftEdge(
    text: Spannable!,
    layout: Layout!
): Boolean

moveToParagraphEnd

Added in API level 34
open static fun moveToParagraphEnd(
    text: Spannable,
    layout: Layout
): Boolean

Move the cursor to the closest paragraph end offset.

Parameters
text Spannable: the spannable text This value cannot be null.
layout Layout: layout to be used for drawing. This value cannot be null.
Return
Boolean true if the cursor is moved, otherwise false.

moveToParagraphStart

Added in API level 34
open static fun moveToParagraphStart(
    text: Spannable,
    layout: Layout
): Boolean

Move the cusrot to the closest paragraph start offset.

Parameters
text Spannable: the spannable text This value cannot be null.
layout Layout: layout to be used for drawing. This value cannot be null.
Return
Boolean true if the cursor is moved, otherwise false.

moveToRightEdge

Added in API level 1
open static fun moveToRightEdge(
    text: Spannable!,
    layout: Layout!
): Boolean

moveUp

Added in API level 1
open static fun moveUp(
    text: Spannable!,
    layout: Layout!
): Boolean

Move the cursor to the buffer offset physically above the current offset, to the beginning if it is on the top line but not at the start, or return false if the cursor is already on the top line.

removeSelection

Added in API level 1
static fun removeSelection(text: Spannable!): Unit

Remove the selection or cursor, if any, from the text.

selectAll

Added in API level 1
static fun selectAll(text: Spannable!): Unit

Select the entire text.

setSelection

Added in API level 1
open static fun setSelection(
    text: Spannable!,
    start: Int,
    stop: Int
): Unit

Set the selection anchor to start and the selection edge to stop.

setSelection

Added in API level 1
static fun setSelection(
    text: Spannable!,
    index: Int
): Unit

Move the cursor to offset index.

Properties

SELECTION_END

Added in API level 1
static val SELECTION_END: Any!

SELECTION_START

Added in API level 1
static val SELECTION_START: Any!