FragmentStateAdapter
Similar in behavior to FragmentStatePagerAdapter
Lifecycle within RecyclerView:
- RecyclerView.ViewHolder initially an empty FrameLayout, serves as a re-usable container for a Fragment in later stages.
- onBindViewHolder we ask for a Fragment for the position. If we already have the fragment, or have previously saved its state, we use those.
- onAttachedToWindow we attach the Fragment to a container.
- onViewRecycled we remove, save state, destroy the Fragment.
Types
Link copied to clipboard
annotation class ExperimentalFragmentStateAdapterApi
Link copied to clipboard
Callback interface for listening to fragment lifecycle changes that happen inside the adapter.
Functions
Link copied to clipboard
Default implementation works for collections that don't add, move, remove items.
Link copied to clipboard
Provide a new Fragment associated with the specified position.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun registerFragmentTransactionCallback(@NonNull callback: FragmentStateAdapter.FragmentTransactionCallback)
Registers a FragmentTransactionCallback to listen to fragment lifecycle changes that happen inside the adapter.
Link copied to clipboard
Restores adapter state
Link copied to clipboard
Saves adapter state
Link copied to clipboard
Link copied to clipboard
open fun unregisterFragmentTransactionCallback(@NonNull callback: FragmentStateAdapter.FragmentTransactionCallback)
Unregisters a FragmentTransactionCallback.