# LeanbackListPreferenceDialogFragment.AdapterSingle

Artifact: [androidx.leanback:leanback-preference](https://developer.android.com/jetpack/androidx/releases/leanback) [View Source](https://cs.android.com/search?q=file:androidx/leanback/preference/LeanbackListPreferenceDialogFragment.java+class:androidx.leanback.preference.LeanbackListPreferenceDialogFragment.AdapterSingle) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***


```
inner class LeanbackListPreferenceDialogFragment.AdapterSingle : RecyclerView.Adapter<LeanbackListPreferenceDialogFragment.ViewHolder!>, LeanbackListPreferenceDialogFragment.ViewHolder.OnItemClickListener
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.recyclerview.widget.RecyclerView.Adapter](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter)\<[LeanbackListPreferenceDialogFragment.ViewHolder](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.ViewHolder)!\> ||
|   | ↳ | [androidx.leanback.preference.LeanbackListPreferenceDialogFragment.AdapterSingle](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle) |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use LeanbackListPreferenceDialogFragmentCompat.

Adapter for single choice.

## Summary

| ### Public constructors |
|---|
| `[AdapterSingle](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#AdapterSingle(java.lang.CharSequence[],java.lang.CharSequence[],java.lang.CharSequence))( entries: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!, entryValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!, selectedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html! )` **This function is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getItemCount](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#getItemCount())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onBindViewHolder](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#onBindViewHolder(androidx.leanback.preference.LeanbackListPreferenceDialogFragment.ViewHolder,int))( holder: https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.ViewHolder!, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.ViewHolder!` | `[onCreateViewHolder](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#onCreateViewHolder(android.view.ViewGroup,int))(parent: https://developer.android.com/reference/android/view/ViewGroup.html!, viewType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onItemClick](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#onItemClick(androidx.leanback.preference.LeanbackListPreferenceDialogFragment.ViewHolder))( viewHolder: https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.ViewHolder! )` **This function is deprecated.** Deprecated in Java |

### Inherited functions

From [androidx.recyclerview.widget.RecyclerView.Adapter](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[bindViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#bindViewHolder(VH,int))(holder: VH, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`VH` `[createViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#createViewHolder(android.view.ViewGroup,int))(parent: https://developer.android.com/reference/android/view/ViewGroup.html, viewType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `[findRelativeAdapterPositionIn](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#findRelativeAdapterPositionIn(androidx.recyclerview.widget.RecyclerView.Adapter<? extends androidx.recyclerview.widget.RecyclerView.ViewHolder>,androidx.recyclerview.widget.RecyclerView.ViewHolder,int))(
adapter: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter<https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder!>,
viewHolder: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder,
localPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html
)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `[getItemId](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getItemId(int))(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `[getItemViewType](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getItemViewType(int))(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy` `[getStateRestorationPolicy](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getStateRestorationPolicy())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[hasObservers](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#hasObservers())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[hasStableIds](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#hasStableIds())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyDataSetChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyDataSetChanged())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int))(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int,java.lang.Object))(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemInserted](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemInserted(int))(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemMoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemMoved(int,int))(fromPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, toPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemRangeChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeChanged(int,int))(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemRangeChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeChanged(int,int,java.lang.Object))(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemRangeInserted](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeInserted(int,int))(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemRangeRemoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeRemoved(int,int))(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[notifyItemRemoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRemoved(int))(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onAttachedToRecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onAttachedToRecyclerView(androidx.recyclerview.widget.RecyclerView))(recyclerView: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onBindViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int,java.util.List<java.lang.Object>))(holder: VH, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payloads: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!>)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onDetachedFromRecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onDetachedFromRecyclerView(androidx.recyclerview.widget.RecyclerView))(recyclerView: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[onFailedToRecycleView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onFailedToRecycleView(VH))(holder: VH)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onViewAttachedToWindow](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onViewAttachedToWindow(VH))(holder: VH)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onViewDetachedFromWindow](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onViewDetachedFromWindow(VH))(holder: VH)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onViewRecycled](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onViewRecycled(VH))(holder: VH)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[registerAdapterDataObserver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver))(observer: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.AdapterDataObserver)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setHasStableIds](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#setHasStableIds(boolean))(hasStableIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setStateRestorationPolicy](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy))(
strategy: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy
)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[unregisterAdapterDataObserver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver))(
observer: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.AdapterDataObserver
)`

**This function is deprecated.** Deprecated in Java

## Public constructors

### AdapterSingle

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

```
[AdapterSingle](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#AdapterSingle(java.lang.CharSequence[],java.lang.CharSequence[],java.lang.CharSequence))(
    entries: Array<CharSequence!>!,
    entryValues: Array<CharSequence!>!,
    selectedValue: CharSequence!
)
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

## Public functions

### getItemCount

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

```
fun [getItemCount](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#getItemCount())(): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns the total number of items in the data set held by the adapter.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The total number of items in this adapter. |

### onBindViewHolder

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

```
fun [onBindViewHolder](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#onBindViewHolder(androidx.leanback.preference.LeanbackListPreferenceDialogFragment.ViewHolder,int))(
    holder: LeanbackListPreferenceDialogFragment.ViewHolder!,
    position: Int
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Called by RecyclerView to display the data at the specified position. This method should update the contents of the `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder#itemView()` to reflect the item at the given position.

Note that unlike `https://developer.android.com/reference/android/widget/ListView.html`, RecyclerView will not call this method again if the position of the item changes in the data set unless the item itself is invalidated or the new position cannot be determined. For this reason, you should only use the `position` parameter while acquiring the related data item inside this method and should not keep a copy of it. If you need the position of an item later on (e.g. in a click listener), use `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder#getBindingAdapterPosition()` which will have the updated adapter position. Override `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int,java.util.List<java.lang.Object>)` instead if Adapter can handle efficient partial bind.

| Parameters |
|---|---|
| `holder: https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.ViewHolder!` | The ViewHolder which should be updated to represent the contents of the item at the given position in the data set. |
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The position of the item within the adapter's data set. |

### onCreateViewHolder

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

```
fun [onCreateViewHolder](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#onCreateViewHolder(android.view.ViewGroup,int))(parent: ViewGroup!, viewType: Int): LeanbackListPreferenceDialogFragment.ViewHolder!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Called when RecyclerView needs a new `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder` of the given type to represent an item.

This new ViewHolder should be constructed with a new View that can represent the items of the given type. You can either create a new View manually or inflate it from an XML layout file.

The new ViewHolder will be used to display items of the adapter using `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int,java.util.List<java.lang.Object>)`. Since it will be re-used to display different items in the data set, it is a good idea to cache references to sub views of the View to avoid unnecessary `https://developer.android.com/reference/android/view/View.html#findViewById(int)` calls.

| Parameters |
|---|---|
| `parent: https://developer.android.com/reference/android/view/ViewGroup.html!` | The ViewGroup into which the new View will be added after it is bound to an adapter position. |
| `viewType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The view type of the new View. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.ViewHolder!` | A new ViewHolder that holds a View of the given view type. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#getItemViewType(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int)` |   |

### onItemClick

```
fun [onItemClick](https://developer.android.com/reference/kotlin/androidx/leanback/preference/LeanbackListPreferenceDialogFragment.AdapterSingle#onItemClick(androidx.leanback.preference.LeanbackListPreferenceDialogFragment.ViewHolder))(
    viewHolder: LeanbackListPreferenceDialogFragment.ViewHolder!
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java