ListItemAdapter

open class ListItemAdapter : PagedListView.ItemCap, PagedListView.DividerVisibilityManager
kotlin.Any
   ↳ androidx.car.widget.ListItemAdapter

Adapter for PagedListView to display ListItem.

To enable support for CarUxRestrictions, call #start() in your Activity's android.app.Activity#onCreate(Bundle), and #stop() in Activity#onStop().

Summary

Nested classes

Constant class for background style of items.

Inherited constants
Public constructors
<init>(context: Context!, itemProvider: ListItemProvider!)

Defaults BackgroundStyle to BackgroundStyle#SOLID.

<init>(context: Context!, itemProvider: ListItemProvider!, backgroundStyle: Int)

Public methods
open Unit
registerListItemViewType(viewType: Int, layoutResId: Int, function: Function<View!, ListItem.ViewHolder!>!)

Registers a function that returns RecyclerView.

open Unit
setMaxItems(maxItems: Int)

open ListItem.ViewHolder!
onCreateViewHolder(parent: ViewGroup!, viewType: Int)

open Boolean

open Unit

open Unit
onAttachedToRecyclerView(recyclerView: RecyclerView!)

open Int
getItemViewType(position: Int)

open Int

open Unit

Enables support for CarUxRestrictions.

open Unit

Disables support for CarUxRestrictions, and frees up resources.

Public constructors

<init>

ListItemAdapter(context: Context!, itemProvider: ListItemProvider!)

Defaults BackgroundStyle to BackgroundStyle#SOLID.

<init>

ListItemAdapter(context: Context!, itemProvider: ListItemProvider!, backgroundStyle: Int)

Public methods

registerListItemViewType

open fun registerListItemViewType(viewType: Int, layoutResId: Int, function: Function<View!, ListItem.ViewHolder!>!): Unit

Registers a function that returns RecyclerView.ViewHolder for its matching view type returned by ListItem#getViewType().

The function will receive a view as RecyclerView.ViewHolder#itemView. This view uses background defined by BackgroundStyle.

Subclasses of ListItem in package androidx.car.widget are already registered.

Parameters
viewType Int: use negative value for custom view type.
function Int: function to create ViewHolder for viewType.

setMaxItems

open fun setMaxItems(maxItems: Int): Unit

onCreateViewHolder

open fun onCreateViewHolder(parent: ViewGroup!, viewType: Int): ListItem.ViewHolder!

shouldHideDivider

open fun shouldHideDivider(position: Int): Boolean

onBindViewHolder

open fun onBindViewHolder(holder: ListItem.ViewHolder!, position: Int): Unit

onAttachedToRecyclerView

open fun onAttachedToRecyclerView(recyclerView: RecyclerView!): Unit

getItemViewType

open fun getItemViewType(position: Int): Int

getItemCount

open fun getItemCount(): Int

start

open fun start(): Unit

Enables support for CarUxRestrictions.

This method can be called from Activity's Activity#onStart(), or at the time of construction.

This method must be accompanied with a matching #stop() to avoid leak.

stop

open fun stop(): Unit

Disables support for CarUxRestrictions, and frees up resources.

This method should be called from Activity's Activity#onStop(), or at the time of this adapter being discarded.