ViewModelProvider.KeyedFactory

public static interface ViewModelProvider.KeyedFactory

androidx.lifecycle.ViewModelProvider.KeyedFactory


Implementations of Factory interface are responsible to instantiate ViewModels.

This is more advanced version of ViewModelProvider.Factory that receives a key specified for requested ViewModel.

Summary

Public methods

abstract <T extends ViewModel> T create(String key, Class<T> modelClass)

Creates a new instance of the given Class.

Public methods

create

public abstract T create (String key,
                Class<T> modelClass)

Creates a new instance of the given Class.

Parameters
key String: a key associated with the requested ViewModel

modelClass Class: a Class whose instance is requested

Returns
T a newly created ViewModel