AccessibilityNodeInfoCompat.SelectionPositionCompat


public final class AccessibilityNodeInfoCompat.SelectionPositionCompat


Compat class for AccessibilityNodeInfo.SelectionPosition, which is a class that defines either the start or end of a selection that can span across multiple AccessibilityNodeInfo objects.

See also
AccessibilityNodeInfo.SelectionPosition

Compatibility:

  • API <: 36.1: Class methods perform no-op behavior.

Summary

Constants

static final int

The offset represents a position between the children of this position's node, used with getChild.

static final int

The offset represents an index into the text returned by getText.

Public constructors

Instantiates a new SelectionPositionCompat.

SelectionPositionCompat(
    @NonNull AccessibilityNodeInfoCompat node,
    int offset
)

Instantiates a new SelectionPositionCompat.

SelectionPositionCompat(@NonNull View view, int offset)

Instantiates a new SelectionPositionCompat.

SelectionPositionCompat(
    @NonNull View view,
    int virtualDescendantId,
    int offset
)

Instantiates a new SelectionPositionCompat.

Public methods

boolean
equals(Object other)

Compatibility:

@Nullable AccessibilityNodeInfoCompat

Returns the node associated with thisSelectionPositionCompat Compatibility:

int

Returns value from 0 to the length of getNode's content representing the offset of the SelectionPositionCompat Compatibility:

int

Returns the offset type.

@Nullable View

Returns the view associated with thisSelectionPositionCompat.

int

Returns a value representing the virtual descendant id of the SelectionPositionCompat Compatibility:

int

Compatibility:

Constants

OFFSET_TYPE_CHILD

Added in 1.20.0-rc01
@PreviewAccessibilityApi
public static final int OFFSET_TYPE_CHILD = 1

The offset represents a position between the children of this position's node, used with getChild. The offset bounds are from 0 to getChildCount, inclusive. An offset of 0 represents the position conceptually before the first child, and an offset equal to the child count represents the position after the last child.

OFFSET_TYPE_TEXT

Added in 1.20.0-rc01
@PreviewAccessibilityApi
public static final int OFFSET_TYPE_TEXT = 0

The offset represents an index into the text returned by getText.

Public constructors

SelectionPositionCompat

Added in 1.18.0
public SelectionPositionCompat(
    @NonNull AccessibilityNodeInfo.SelectionPosition position
)

Instantiates a new SelectionPositionCompat.

Parameters
@NonNull AccessibilityNodeInfo.SelectionPosition position

The underlying SelectionPosition to wrap.

SelectionPositionCompat

Added in 1.18.0
public SelectionPositionCompat(
    @NonNull AccessibilityNodeInfoCompat node,
    int offset
)

Instantiates a new SelectionPositionCompat.

Parameters
@NonNull AccessibilityNodeInfoCompat node

The AccessibilityNodeInfoCompat for the node of this selection position.

int offset

The offset for a SelectionPositionCompat within view's text content, which should be a value between 0 and the length of view's text.

SelectionPositionCompat

Added in 1.18.0
public SelectionPositionCompat(@NonNull View view, int offset)

Instantiates a new SelectionPositionCompat.

Parameters
@NonNull View view

The View containing the text associated with this selection position.

int offset

The offset for a selection position within view's text content, which should be a value between 0 and the length of view's text.

SelectionPositionCompat

Added in 1.18.0
public SelectionPositionCompat(
    @NonNull View view,
    int virtualDescendantId,
    int offset
)

Instantiates a new SelectionPositionCompat.

Parameters
@NonNull View view

The view whose virtual descendant is associated with the selection position.

int virtualDescendantId

The ID of the virtual descendant within view's virtual subtree that contains the selection position.

int offset

The offset for a selection position within the virtual descendant's text content, which should be a value between 0 and the length of the descendant's text.

Public methods

equals

public boolean equals(Object other)

Compatibility:

  • API <: 36.1: Returns true if this object is identical to other, else false

getNode

Added in 1.18.0
public @Nullable AccessibilityNodeInfoCompat getNode()

Returns the node associated with thisSelectionPositionCompat Compatibility:

  • API <: 36.1: Always returns null
Returns
@Nullable AccessibilityNodeInfoCompat

the associated node, or null

getOffset

Added in 1.18.0
public int getOffset()

Returns value from 0 to the length of getNode's content representing the offset of the SelectionPositionCompat Compatibility:

  • API <: 36.1: Always returns -1
Returns
int

the offset value, or -1

getOffsetType

Added in 1.20.0-rc01
@PreviewAccessibilityApi
public int getOffsetType()

Returns the offset type. If this instance was created without specifying an offset type, this will default to OFFSET_TYPE_TEXT.

getView

Added in 1.19.0
public @Nullable View getView()

Returns the view associated with thisSelectionPositionCompat. Will return null if the view is not attached to a window. Compatibility:

  • API <: 36.1: Always returns null
Returns
@Nullable View

the associated view, or null

getVirtualDescendantId

Added in 1.19.0
public int getVirtualDescendantId()

Returns a value representing the virtual descendant id of the SelectionPositionCompat Compatibility:

  • API <: 36.1: Always returns -1
Returns
int

the virutla descendant id, or null

hashCode

public int hashCode()

Compatibility:

  • API <: 36.1: Always returns 0