# AccessibilityNodeInfoCompat.CollectionItemInfoCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/accessibility/AccessibilityNodeInfoCompat.java+class:androidx.core.view.accessibility.AccessibilityNodeInfoCompat.CollectionItemInfoCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public class AccessibilityNodeInfoCompat.CollectionItemInfoCompat
```

<br />

*** ** * ** ***

Class with information if a node is a collection item.

A collection item is contained in a collection, it starts at a given row and column in the collection, and spans one or more rows and columns. For example, a header of two related table columns starts at the first row and the first column, spans one row and two columns.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat.Builder` Builder for creating `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat` objects. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#SORT_DIRECTION_ASCENDING() = 1` Items are sorted in ascending order (e.g., A-Z, 0-9). |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#SORT_DIRECTION_DESCENDING() = 2` Items are sorted in descending order (e.g., Z-A, 9-0). |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#SORT_DIRECTION_NONE() = 0` There is no sort direction. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#SORT_DIRECTION_OTHER() = 3` Items are sorted, but using a method other than ascending or descending (e.g., based on relevance or a custom algorithm). |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getColumnIndex()()` Gets the column index at which the item is located. |
| `int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getColumnSpan()()` Gets the number of columns the item spans. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getColumnTitle()()` Gets the column title at which the item is located. |
| `int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getRowIndex()()` Gets the row index at which the item is located. |
| `int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getRowSpan()()` Gets the number of rows the item spans. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getRowTitle()()` Gets the row title at which the item is located. |
| `int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getSortDirection()()` Gets the sort direction applied to the data associated with this node. |
| `boolean` | `[isHeading](https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#isHeading())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#isHeading()` <br /> |
| `boolean` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#isSelected()()` Gets if the collection item is selected. |
| `static https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#obtain(int,int,int,int,boolean)( int rowIndex, int rowSpan, int columnIndex, int columnSpan, boolean heading )` Returns a cached instance if such is available otherwise a new one. |
| `static https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#obtain(int,int,int,int,boolean,boolean)( int rowIndex, int rowSpan, int columnIndex, int columnSpan, boolean heading, boolean selected )` Returns a cached instance if such is available otherwise a new one. |

## Constants

### SORT_DIRECTION_ASCENDING

Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

```
public static final int SORT_DIRECTION_ASCENDING = 1
```

Items are sorted in ascending order (e.g., A-Z, 0-9).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getSortDirection()` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat.Builder#setSortDirection(int)` |   |

### SORT_DIRECTION_DESCENDING

Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

```
public static final int SORT_DIRECTION_DESCENDING = 2
```

Items are sorted in descending order (e.g., Z-A, 9-0).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getSortDirection()` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat.Builder#setSortDirection(int)` |   |

### SORT_DIRECTION_NONE

Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

```
public static final int SORT_DIRECTION_NONE = 0
```

There is no sort direction.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getSortDirection()` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat.Builder#setSortDirection(int)` |   |

### SORT_DIRECTION_OTHER

Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

```
public static final int SORT_DIRECTION_OTHER = 3
```

Items are sorted, but using a method other than ascending or descending (e.g., based on relevance or a custom algorithm).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#getSortDirection()` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat.Builder#setSortDirection(int)` |   |

## Public methods

### getColumnIndex

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int getColumnIndex()
```

Gets the column index at which the item is located.

| Returns |
|---|---|
| `int` | The column index. |

### getColumnSpan

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int getColumnSpan()
```

Gets the number of columns the item spans.

| Returns |
|---|---|
| `int` | The column span. |

### getColumnTitle

Added in [1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)

```
public @Nullable String getColumnTitle()
```

Gets the column title at which the item is located.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | The column title. |

### getRowIndex

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int getRowIndex()
```

Gets the row index at which the item is located.

| Returns |
|---|---|
| `int` | The row index. |

### getRowSpan

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int getRowSpan()
```

Gets the number of rows the item spans.

| Returns |
|---|---|
| `int` | The row span. |

### getRowTitle

Added in [1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)

```
public @Nullable String getRowTitle()
```

Gets the row title at which the item is located.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | The row title. |

### getSortDirection

Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

```
public int getSortDirection()
```

Gets the sort direction applied to the data associated with this node.

This item can only be set on a heading node within a table collection. Given the heading node's collection item, a subsequent collection item uses this sort direction if it has the same row or column index, and a greater index in the other dimension. For example, an item at row 2, column 2 can reference a heading at row 2, column 1 for its sort direction.

Compatibility:

- API \<36.1: Always returns SORT_DIRECTION_NONE

| Returns |
|---|---|
| `int` | The current sort direction. |

### isHeading

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean [isHeading](https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat#isHeading())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#isHeading()`

Gets if the collection item is a heading. For example, section heading, table header, etc.

| Returns |
|---|---|
| `boolean` | If the item is a heading. |

### isSelected

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean isSelected()
```

Gets if the collection item is selected.

| Returns |
|---|---|
| `boolean` | If the item is selected. |

### obtain

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static AccessibilityNodeInfoCompat.CollectionItemInfoCompat obtain(
    int rowIndex,
    int rowSpan,
    int columnIndex,
    int columnSpan,
    boolean heading
)
```

Returns a cached instance if such is available otherwise a new one.

| Parameters |
|---|---|
| `int rowIndex` | The row index at which the item is located. |
| `int rowSpan` | The number of rows the item spans. |
| `int columnIndex` | The column index at which the item is located. |
| `int columnSpan` | The number of columns the item spans. |
| `boolean heading` | Whether the item is a heading. This should be set to false and the newer `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setHeading(boolean)` used to identify headings. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat` | An instance. |

### obtain

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static AccessibilityNodeInfoCompat.CollectionItemInfoCompat obtain(
    int rowIndex,
    int rowSpan,
    int columnIndex,
    int columnSpan,
    boolean heading,
    boolean selected
)
```

Returns a cached instance if such is available otherwise a new one.

| Parameters |
|---|---|
| `int rowIndex` | The row index at which the item is located. |
| `int rowSpan` | The number of rows the item spans. |
| `int columnIndex` | The column index at which the item is located. |
| `int columnSpan` | The number of columns the item spans. |
| `boolean heading` | Whether the item is a heading. This should be set to false and the newer `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setHeading(boolean)` used to identify headings. |
| `boolean selected` | Whether the item is selected. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionItemInfoCompat` | An instance. |