Package-level declarations

Types

Link copied to clipboard
A fragment that displays a dialog window, floating in the foreground of its activity's window.
Link copied to clipboard
Link copied to clipboard
abstract class FragmentContainer
Callbacks to a Fragment's container.
Link copied to clipboard

FragmentContainerView is a customized Layout designed specifically for Fragments. It extends FrameLayout, so it can reliably handle Fragment Transactions, and it also has additional features to coordinate with fragment behavior.

Link copied to clipboard
Provides integration points with a FragmentManager for a fragment host.
Link copied to clipboard
open class FragmentFactory
Interface used to control the instantiation of Fragment instances.
Link copied to clipboard

Integration points with the Fragment host.

Link copied to clipboard
Static library support version of the framework's android.app.FragmentManager.
Link copied to clipboard
FragmentManagerNonConfig stores the retained instance fragments across activity recreation events.
Link copied to clipboard
Listener for receiving a callback immediately following onAttach.
Link copied to clipboard
Implementation of PagerAdapter that represents each page as a Fragment that is persistently kept in the fragment manager as long as the user can return to the page.
Link copied to clipboard
Listener for handling fragment results.
Link copied to clipboard
A class that manages passing data between fragments.
Link copied to clipboard
Implementation of PagerAdapter that uses a Fragment to manage each page.
Link copied to clipboard
Special TabHost that allows the use of Fragment objects for its tab content.
Link copied to clipboard
abstract class FragmentTransaction
Static library support version of the framework's android.app.FragmentTransaction.
Link copied to clipboard
Link copied to clipboard
open class ListFragment : Fragment
Static library support version of the framework's android.app.ListFragment.
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class PredictiveBackControl
Link copied to clipboard
Helper for constructing and updating predictive back and standard fragment transition animators on One UI.

Functions

Link copied to clipboard
inline fun <VM : ViewModel> Fragment.activityViewModels(noinline extrasProducer: () -> CreationExtras? = null, noinline factoryProducer: () -> ViewModelProvider.Factory? = null): Lazy<VM>

Returns a property delegate to access parent activity's ViewModel, if factoryProducer is specified then ViewModelProvider.Factory returned by it will be used to create ViewModel first time. Otherwise, the activity's default factory will be used.

Link copied to clipboard
inline fun <F : Fragment> FragmentTransaction.add(tag: String, args: Bundle? = null): FragmentTransaction

Add a fragment to the associated FragmentManager without adding the Fragment to any container view.

inline fun <F : Fragment> FragmentTransaction.add(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null): FragmentTransaction

Add a fragment to the associated FragmentManager, inflating the Fragment's view into the container view specified by containerViewId, to later retrieve via FragmentManager.findFragmentById.

Link copied to clipboard

Clears the stored result for the given requestKey.

Link copied to clipboard

Clears the stored FragmentResultListener for the given requestKey.

Link copied to clipboard
inline fun FragmentManager.commit(allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

Run body in a FragmentTransaction which is automatically committed if it completes without exception.

Link copied to clipboard
inline fun FragmentManager.commitNow(allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

Run body in a FragmentTransaction which is automatically committed if it completes without exception.

Link copied to clipboard
fun <VM : ViewModel> Fragment.createViewModelLazy(viewModelClass: KClass<VM>, storeProducer: () -> ViewModelStore, extrasProducer: () -> CreationExtras = { defaultViewModelCreationExtras }, factoryProducer: () -> ViewModelProvider.Factory? = null): Lazy<VM>

Helper method for creation of ViewModelLazy, that resolves null passed as factoryProducer to default factory.

Link copied to clipboard

Find a Fragment associated with a View.

Link copied to clipboard
inline fun <F : Fragment> FragmentTransaction.replace(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null): FragmentTransaction

Replace an existing fragment that was added to a container. This is essentially the same as calling remove for all currently added fragments that were added with the same containerViewId and then add with the same arguments given here.

Link copied to clipboard
fun Fragment.setFragmentResult(requestKey: String, result: Bundle)

Sets the given result for the requestKey. This result will be delivered to a FragmentResultListener that is called given to setFragmentResultListener with the same requestKey. If no FragmentResultListener with the same key is set or the Lifecycle associated with the listener is not at least androidx.lifecycle.Lifecycle.State.STARTED, the result is stored until one becomes available, or clearFragmentResult is called with the same requestKey.

Link copied to clipboard
fun Fragment.setFragmentResultListener(requestKey: String, listener: (requestKey: String, bundle: Bundle) -> Unit)

Sets the FragmentResultListener for a given requestKey. Once this Fragment is at least in the androidx.lifecycle.Lifecycle.State.STARTED state, any results set by setFragmentResult using the same requestKey will be delivered to the FragmentResultListener.onFragmentResult callback. The callback will remain active until this Fragment reaches the androidx.lifecycle.Lifecycle.State.DESTROYED state or clearFragmentResultListener is called with the same requestKey.

Link copied to clipboard
inline fun FragmentManager.transaction(now: Boolean = false, allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

Run body in a FragmentTransaction which is automatically committed if it completes without exception.

Link copied to clipboard
inline fun <VM : ViewModel> Fragment.viewModels(noinline ownerProducer: () -> ViewModelStoreOwner = { this }, noinline extrasProducer: () -> CreationExtras? = null, noinline factoryProducer: () -> ViewModelProvider.Factory? = null): Lazy<VM>

Returns a property delegate to access ViewModel by default scoped to this Fragment: