ViewModelProvider.Factory


Known direct subclasses
AbstractSavedStateViewModelFactory

Skeleton of androidx.lifecycle.ViewModelProvider.KeyedFactory that creates SavedStateHandle for every requested ViewModel.

SavedStateViewModelFactory

androidx.lifecycle.ViewModelProvider.Factory that can create ViewModels accessing and contributing to a saved state via SavedStateHandle received in a constructor.

ViewModelProvider.NewInstanceFactory

Simple factory, which calls empty constructor on the give class.


Implementations of Factory interface are responsible to instantiate ViewModels.

Summary

Public functions

open T
<T : ViewModel> create(modelClass: KClass<T>, extras: CreationExtras)

Creates a new instance of the given Class.

Cmn
android
N

Public functions

create

open fun <T : ViewModel> create(modelClass: KClass<T>, extras: CreationExtras): T

Creates a new instance of the given Class.

Parameters
modelClass: KClass<T>

a KClass whose instance is requested

extras: CreationExtras

an additional information for this creation request

Returns
T

a newly created ViewModel