create

abstract fun create(parent: ViewGroup): View

Creates a header view within the given parent.

If you want to alternate the styling for individual headers in the list, use data binding to inflate a layout. The viewModel variable in the binding will be set to the ListItemHeaderViewModel that this list item represents.

It's possible to base styling on additional fields by subclassing ListItemHeaderViewModel. Do make sure that all header items in the list are of this subclass, since binding will otherwise crash with a casting error.

If the styling differs per header list item, it's possible to create a custom layout and use data binding to provide the correct styling for each header item. This layout can be inflated by using the LayoutHeaderListItemViewFactory.

Parameters

parent

The parent ViewGroup which implementations can use when inflating layouts and to access a Context. Passing the parent when inflating a layout ensures the resultant view will inherit the layout's LayoutParams (in particular the layout_width and layout_height values which would otherwise default to WRAP_CONTENT).