ViewModelProvider.AndroidViewModelFactory

public class ViewModelProvider.AndroidViewModelFactory extends ViewModelProvider.NewInstanceFactory implements ViewModelProvider.Factory


Factory which may create AndroidViewModel and ViewModel, which have an empty constructor.

Summary

Public constructors

Public methods

@NonNull T
<T extends ViewModel> create(Class<T> modelClass)

Creates a new instance of the given Class.

Public constructors

AndroidViewModelFactory

public final AndroidViewModelFactory(Application application)
Parameters
Application application

an application to pass in AndroidViewModel

Public methods

create

public @NonNull T <T extends ViewModel> create(Class<T> modelClass)

Creates a new instance of the given Class.

Parameters
Class<T> modelClass

a Class whose instance is requested

Returns
@NonNull T

a newly created ViewModel