Signature
Explore example code
Browse the example code on GitHub.
About this widget
Requirements
Declare each facet attribute inattributesForFaceting.
Configure the facet order in the Algolia dashboard or
with renderingContent.
Set the query’s facets property and include each facet attribute to retrieve.
Dynamic facet list requires InstantSearch Android v2.1.1 or later.
Example
Create aDynamicFacetListConnector, set the query’s facets, and run the initial search.
Kotlin
Parameters
FilterState
required
The
FilterState that stores the current filters.List<AttributedFacets>
default: []
The initial ordered facets.
SelectionsPerAttribute
default: []
Maps each facet attribute to its selected facet values.
Map<String, SelectionMode>
default: [:]
Maps each facet attribute to its facet-value selection mode.
The default mode is
Single.Map<String, FilterGroupDescriptor>
default: [:]
Maps each facet attribute to the filter group that stores its filters in the filter state.
View
DynamicFacetListView
required
The view that renders the dynamic facet list.
Kotlin
Low-level API
Use the following components to connect the dynamic facet list:Searcher: runs searches.FilterState: stores the current filter state.DynamicFacetsListViewModel: manages dynamic facet state and behavior.
Kotlin
Customize the view
TheDynamicFacetListView interface displays the ordered facets and handles user interactions.
Use this interface to provide a custom view:
Kotlin
Android views
DynamicFacetListAdapter is a built-in implementation of DynamicFacetListView that extends ListAdapter.
Pass a DynamicFacetListViewHolder.Factory implementation to the adapter:
Kotlin
Compose UI
DynamicFacetListState implements DynamicFacetListView for Compose UI.
Use its facetOrder and facetSelections properties and its toggle and isSelected functions to build a custom Compose UI.
Implementation example
Kotlin