Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

ViewTreeSavedStateRegistryOwner

class ViewTreeSavedStateRegistryOwner
kotlin.Any
   ↳ androidx.savedstate.ViewTreeSavedStateRegistryOwner

Accessors for finding a view tree-local SavedStateRegistryOwner that allows managing the saving state using SavedStateRegistry for the given view.

Summary

Public methods
static SavedStateRegistryOwner?
get(@NonNull view: View)

Retrieve the SavedStateRegistryOwner responsible for managing the saved state for the given View.

static Unit
set(@NonNull view: View, @Nullable owner: SavedStateRegistryOwner?)

Set the SavedStateRegistryOwner responsible for managing the saved state for the given View.

Public methods

get

@Nullable static fun get(@NonNull view: View): SavedStateRegistryOwner?

Retrieve the SavedStateRegistryOwner responsible for managing the saved state for the given View. This may be used to save or restore the state associated with the view. The returned SavedStateRegistryOwner is managing all the Views within the Fragment or Activity the given View is added to.

Parameters
view View: View to fetch a SavedStateRegistryOwner for
Return
SavedStateRegistryOwner? The SavedStateRegistryOwner responsible for managing the saved state for the given view and/or some subset of its ancestors

set

static fun set(
    @NonNull view: View,
    @Nullable owner: SavedStateRegistryOwner?
): Unit

Set the SavedStateRegistryOwner responsible for managing the saved state for the given View. Calls to get(View) from this view or descendants will return owner. This is is automatically set for you in the common cases of using fragments or ComponentActivity.

This should only be called by constructs such as activities or fragments that manage a view tree and their saved state through a SavedStateRegistryOwner. Callers should only set a SavedStateRegistryOwner that will be stable. The associated SavedStateRegistry should be cleared if the view tree is removed and is not guaranteed to later become reattached to a window.

Parameters
view View: Root view managed by SavedStateRegistryOwner
owner SavedStateRegistryOwner?: The SavedStateRegistryOwner responsible for managing the saved state for the given view