# AccessibilityNodeInfoCompat.CollectionInfoCompat

# AccessibilityNodeInfoCompat.CollectionInfoCompat

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.CollectionInfoCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat "View this page in Java")

<br />

```
class AccessibilityNodeInfoCompat.CollectionInfoCompat
```

<br />

*** ** * ** ***

Class with information if a node is a collection.

A collection of items has rows and columns and may be marked as hierarchical.

For example, a list where the items are placed in a vertical layout is a collection with one column and as many rows as the list items. This collection has 3 rows and 1 column and should not be marked as hierarchical since items do not exist at different levels/ranks and there are no nested collections.

- Item 1
- Item 2
- Item 3

A table is a collection with several rows and several columns. This collection has 2 rows and 3 columns and is not marked as hierarchical:

|--------|--------|--------|
| Item 1 | Item 2 | Item 3 |
| Item 4 | Item 5 | Item 6 |

Nested collections could be marked as hierarchical. To add outer and inner collections to the same hierarchy, mark them both as hierarchical.

For example, if you have a collection with two lists - this collection has an outer list with 3 rows and 1 column and an inner list within "Item 2" with 2 rows and 1 - you can mark both the outer list and the inner list as hierarchical to make them part of the same hierarchy. If a collection does not have any ancestor or descendant hierarchical collections, it does not need to be marked as hierarchical.

- Item 1
- Item 2
  - Item 2A
  - Item 2B
- Item 3

To be a valid list, a collection has 1 row and any number of columns or 1 column and any number of rows.

## Summary

|                                                                                                                                                                                        ### Nested types                                                                                                                                                                                         |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[AccessibilityNodeInfoCompat.CollectionInfoCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat.Builder) Class for building[CollectionInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat)objects. |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SELECTION_MODE_MULTIPLE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_MULTIPLE())` = 2` Selection mode where multiple items may be selected. |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SELECTION_MODE_NONE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_NONE())` = 0` Selection mode where items are not selectable.               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SELECTION_MODE_SINGLE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_SINGLE())` = 1` Selection mode where a single item may be selected.      |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [UNDEFINED](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#UNDEFINED())` = -1` Constant to denote a missing collection count.                                  |

|                                                                                         ### Public functions                                                                                          |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                           | [getColumnCount](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#getColumnCount())`()` Gets the number of columns.                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                           | [getImportantForAccessibilityItemCount](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#getImportantForAccessibilityItemCount())`()` Gets the number of items in the collection considered important for accessibility.                                                                                                                                                                                                                                                                                                                                           |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                           | [getItemCount](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#getItemCount())`()` Gets the number of items in the collection.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                           | [getRowCount](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#getRowCount())`()` Gets the number of rows.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                           | [getSelectionMode](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#getSelectionMode())`()` Gets the collection's selection mode.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                   | [isHierarchical](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#isHierarchical())`()` Gets if the collection is a hierarchically ordered.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `java-static `[AccessibilityNodeInfoCompat.CollectionInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat)`!` | [obtain](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#obtain(int,int,boolean))`(rowCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, columnCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, hierarchical: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Returns a cached instance if such is available otherwise a new one.                                                                                                                 |
| `java-static `[AccessibilityNodeInfoCompat.CollectionInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat)`!` | [obtain](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#obtain(int,int,boolean,int))`(` ` rowCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` columnCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` hierarchical: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` selectionMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Returns a cached instance if such is available otherwise a new one. |

## Constants

### SELECTION_MODE_MULTIPLE

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

```
const val SELECTION_MODE_MULTIPLE = 2: Int
```

Selection mode where multiple items may be selected.  

### SELECTION_MODE_NONE

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

```
const val SELECTION_MODE_NONE = 0: Int
```

Selection mode where items are not selectable.  

### SELECTION_MODE_SINGLE

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

```
const val SELECTION_MODE_SINGLE = 1: Int
```

Selection mode where a single item may be selected.  

### UNDEFINED

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

```
const val UNDEFINED = -1: Int
```

Constant to denote a missing collection count. This should be used for`mItemCount`and`mImportantForAccessibilityItemCount`when values for those fields are not known.  

## Public functions

### getColumnCount

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

```
fun getColumnCount(): Int
```

Gets the number of columns.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|----------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The column count, or -1 if count is unknown. |

### getImportantForAccessibilityItemCount

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

```
fun getImportantForAccessibilityItemCount(): Int
```

Gets the number of items in the collection considered important for accessibility.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The count of items important for accessibility, which may be`UNDEFINED`if the count is not known. |

### getItemCount

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

```
fun getItemCount(): Int
```

Gets the number of items in the collection.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The count of items, which may be`UNDEFINED`if the count is not known. |

### getRowCount

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

```
fun getRowCount(): Int
```

Gets the number of rows.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The row count, or -1 if count is unknown. |

### getSelectionMode

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

```
fun getSelectionMode(): Int
```

Gets the collection's selection mode.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The collection's selection mode, one of: - [SELECTION_MODE_NONE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_NONE()) - [SELECTION_MODE_SINGLE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_SINGLE()) - [SELECTION_MODE_MULTIPLE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_MULTIPLE()) |

### isHierarchical

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

```
fun isHierarchical(): Boolean
```

Gets if the collection is a hierarchically ordered.  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the collection is hierarchical. |

### obtain

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

```
java-static fun obtain(rowCount: Int, columnCount: Int, hierarchical: Boolean): AccessibilityNodeInfoCompat.CollectionInfoCompat!
```

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

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------|
| `rowCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)             | The number of rows, or -1 if count is unknown.     |
| `columnCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | The number of columns , or -1 if count is unknown. |
| `hierarchical: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the collection is hierarchical.            |

|                                                                                         Returns                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
| [AccessibilityNodeInfoCompat.CollectionInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat)`!` | An instance. |

### obtain

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

```
java-static fun obtain(
    rowCount: Int,
    columnCount: Int,
    hierarchical: Boolean,
    selectionMode: Int
): AccessibilityNodeInfoCompat.CollectionInfoCompat!
```

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

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `rowCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)             | The number of rows.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `columnCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | The number of columns.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `hierarchical: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the collection is hierarchical.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `selectionMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)        | The collection's selection mode, one of: - [SELECTION_MODE_NONE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_NONE()) - [SELECTION_MODE_SINGLE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_SINGLE()) - [SELECTION_MODE_MULTIPLE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat#SELECTION_MODE_MULTIPLE()) |

|                                                                                         Returns                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
| [AccessibilityNodeInfoCompat.CollectionInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat.CollectionInfoCompat)`!` | An instance. |