belongs to Maven artifact android.arch.lifecycle:extensions:1.1.1
ViewModelProviders
public
class
ViewModelProviders
extends Object
java.lang.Object | |
↳ | android.arch.lifecycle.ViewModelProviders |
Utilities methods for ViewModelStore
class.
Summary
Nested classes | |
---|---|
class |
ViewModelProviders.DefaultFactory
This class was deprecated
in API level 1.1.0.
Use |
Public constructors | |
---|---|
ViewModelProviders()
This constructor was deprecated in API level 1.1.0. This class should not be directly instantiated |
Public methods | |
---|---|
static
ViewModelProvider
|
of(Fragment fragment)
Creates a |
static
ViewModelProvider
|
of(FragmentActivity activity)
Creates a |
static
ViewModelProvider
|
of(Fragment fragment, ViewModelProvider.Factory factory)
Creates a |
static
ViewModelProvider
|
of(FragmentActivity activity, ViewModelProvider.Factory factory)
Creates a |
Inherited methods | |
---|---|
Public constructors
ViewModelProviders
ViewModelProviders ()
This constructor was deprecated
in API level 1.1.0.
This class should not be directly instantiated
Public methods
of
ViewModelProvider of (Fragment fragment)
Creates a ViewModelProvider
, which retains ViewModels while a scope of given
fragment
is alive. More detailed explanation is in ViewModel
.
It uses ViewModelProvider.AndroidViewModelFactory
to instantiate new ViewModels.
Parameters | |
---|---|
fragment |
Fragment : a fragment, in whose scope ViewModels should be retained |
Returns | |
---|---|
ViewModelProvider |
a ViewModelProvider instance |
of
ViewModelProvider of (FragmentActivity activity)
Creates a ViewModelProvider
, which retains ViewModels while a scope of given Activity
is alive. More detailed explanation is in ViewModel
.
It uses ViewModelProvider.AndroidViewModelFactory
to instantiate new ViewModels.
Parameters | |
---|---|
activity |
FragmentActivity : an activity, in whose scope ViewModels should be retained |
Returns | |
---|---|
ViewModelProvider |
a ViewModelProvider instance |
of
ViewModelProvider of (Fragment fragment, ViewModelProvider.Factory factory)
Creates a ViewModelProvider
, which retains ViewModels while a scope of given
fragment
is alive. More detailed explanation is in ViewModel
.
It uses the given ViewModelProvider.Factory
to instantiate new ViewModels.
Parameters | |
---|---|
fragment |
Fragment : a fragment, in whose scope ViewModels should be retained |
factory |
ViewModelProvider.Factory : a Factory to instantiate new ViewModels |
Returns | |
---|---|
ViewModelProvider |
a ViewModelProvider instance |
of
ViewModelProvider of (FragmentActivity activity, ViewModelProvider.Factory factory)
Creates a ViewModelProvider
, which retains ViewModels while a scope of given Activity
is alive. More detailed explanation is in ViewModel
.
It uses the given ViewModelProvider.Factory
to instantiate new ViewModels.
Parameters | |
---|---|
activity |
FragmentActivity : an activity, in whose scope ViewModels should be retained |
factory |
ViewModelProvider.Factory : a Factory to instantiate new ViewModels |
Returns | |
---|---|
ViewModelProvider |
a ViewModelProvider instance |
Annotations
Interfaces
Classes
- AndroidViewModel
- Lifecycle
- LifecycleRegistry
- LifecycleService
- LiveData
- LiveDataReactiveStreams
- MediatorLiveData
- MutableLiveData
- ProcessLifecycleOwner
- ServiceLifecycleDispatcher
- Transformations
- ViewModel
- ViewModelProvider
- ViewModelProvider.AndroidViewModelFactory
- ViewModelProvider.NewInstanceFactory
- ViewModelProviders
- ViewModelProviders.DefaultFactory
- ViewModelStore
- ViewModelStores
Enums
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.