# SelectionPredicates

# SelectionPredicates

Artifact:[androidx.recyclerview:recyclerview-selection](https://developer.android.com/jetpack/androidx/releases/recyclerview)  
[View Source](https://cs.android.com/search?q=file:androidx/recyclerview/selection/SelectionPredicates.java+class:androidx.recyclerview.selection.SelectionPredicates)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/recyclerview/selection/SelectionPredicates "View this page in Java")

<br />

```
class SelectionPredicates
```

<br />

*** ** * ** ***

Utility class for creating SelectionPredicate instances. Provides default implementations for common cases like "single selection" and "select anything".

## Summary

|                                                                             ### Public functions                                                                              |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[SelectionTracker.SelectionPredicate](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/SelectionTracker.SelectionPredicate)`<K!>` | `<K> `[createSelectAnything](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/SelectionPredicates#createSelectAnything())`()` Returns a selection predicate that allows multiples items to be selected, without any restrictions on which items can be selected.          |
| `java-static `[SelectionTracker.SelectionPredicate](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/SelectionTracker.SelectionPredicate)`<K!>` | `<K> `[createSelectSingleAnything](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/SelectionPredicates#createSelectSingleAnything())`()` Returns a selection predicate that allows a single item to be selected, without any restrictions on which item can be selected. |

## Public functions

### createSelectAnything

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

```
java-static fun <K> createSelectAnything(): SelectionTracker.SelectionPredicate<K!>
```

Returns a selection predicate that allows multiples items to be selected, without any restrictions on which items can be selected.  

| Parameters |
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<K>`      | Selection key type. @see[StorageStrategy](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/StorageStrategy)for supported types. |

|                                                                             Returns                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [SelectionTracker.SelectionPredicate](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/SelectionTracker.SelectionPredicate)`<K!>` |   |

### createSelectSingleAnything

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

```
java-static fun <K> createSelectSingleAnything(): SelectionTracker.SelectionPredicate<K!>
```

Returns a selection predicate that allows a single item to be selected, without any restrictions on which item can be selected.  

| Parameters |
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<K>`      | Selection key type. @see[StorageStrategy](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/StorageStrategy)for supported types. |

|                                                                             Returns                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [SelectionTracker.SelectionPredicate](https://developer.android.com/reference/kotlin/androidx/recyclerview/selection/SelectionTracker.SelectionPredicate)`<K!>` |   |