Added in API level 31

SurroundingText


class SurroundingText : Parcelable

Information about the surrounding text around the cursor for use by an input method.

This contains information about the text and the selection relative to the text.

Summary

Inherited constants
Int CONTENTS_FILE_DESCRIPTOR

Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.

Int PARCELABLE_WRITE_RETURN_VALUE

Flag for use with writeToParcel: the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)". Some implementations may want to release resources at this point.

Public constructors
SurroundingText(text: CharSequence, selectionStart: Int, selectionEnd: Int, offset: Int)

Constructor.

Public methods
Int

Int

Returns text offset between the start of the editor's text and the start of the surrounding text.

Int

Returns the text offset of the end of the selection in the surrounding text.

Int

Returns the text offset of the start of the selection in the surrounding text.

CharSequence

Returns the surrounding text around the cursor.

Unit
writeToParcel(out: Parcel, flags: Int)

Flatten this object in to a Parcel.

Public constructors

SurroundingText

Added in API level 31
SurroundingText(
    text: CharSequence,
    selectionStart: Int,
    selectionEnd: Int,
    offset: Int)

Constructor.

Parameters
text CharSequence: The surrounding text. This value cannot be null.
selectionStart Int: The text offset of the start of the selection in the surrounding text. Reversed selection is allowed. Value is 0 or greater
selectionEnd Int: The text offset of the end of the selection in the surrounding text. Reversed selection is allowed. Value is 0 or greater
offset Int: The text offset between the start of the editor's text and the start of the surrounding text. -1 indicates the offset is unknown. Value is -1 or greater

Public methods

describeContents

Added in API level 31
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getOffset

Added in API level 31
fun getOffset(): Int

Returns text offset between the start of the editor's text and the start of the surrounding text.

-1 indicates the offset information is unknown.

Return
Int Value is -1 or greater

getSelectionEnd

Added in API level 31
fun getSelectionEnd(): Int

Returns the text offset of the end of the selection in the surrounding text.

A selection is the current range of the text that is selected by the user, or the current position of the cursor. A cursor is a selection where the start and end are at the same offset.

Return
Int Value is 0 or greater

getSelectionStart

Added in API level 31
fun getSelectionStart(): Int

Returns the text offset of the start of the selection in the surrounding text.

A selection is the current range of the text that is selected by the user, or the current position of the cursor. A cursor is a selection where the start and end are at the same offset.

Return
Int Value is 0 or greater

getText

Added in API level 31
fun getText(): CharSequence

Returns the surrounding text around the cursor.

Return
CharSequence This value cannot be null.

writeToParcel

Added in API level 31
fun writeToParcel(
    out: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES
out Parcel: This value cannot be null.

Properties

CREATOR

Added in API level 31
static val CREATOR: Parcelable.Creator<SurroundingText!>