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(@NonNull Class<@NonNull T> modelClass)

Creates a new instance of the given Class.

Public constructors

AndroidViewModelFactory

public final AndroidViewModelFactory(@NonNull Application application)
Parameters
@NonNull Application application

an application to pass in AndroidViewModel

Public methods

create

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

Creates a new instance of the given Class.

Parameters
@NonNull Class<@NonNull T> modelClass

a Class whose instance is requested

Returns
T

a newly created ViewModel