Aracılığıyla paylaş


View.OnSaveInstanceState Method

Definition

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.

[Android.Runtime.Register("onSaveInstanceState", "()Landroid/os/Parcelable;", "GetOnSaveInstanceStateHandler")]
protected virtual Android.OS.IParcelable? OnSaveInstanceState ();
[<Android.Runtime.Register("onSaveInstanceState", "()Landroid/os/Parcelable;", "GetOnSaveInstanceStateHandler")>]
abstract member OnSaveInstanceState : unit -> Android.OS.IParcelable
override this.OnSaveInstanceState : unit -> Android.OS.IParcelable

Returns

Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.

Attributes

Remarks

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.

Java documentation for android.view.View.onSaveInstanceState().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also