Language

Fragment.OnInflate Method

Definition

Overloads

Name Description
OnInflate(IAttributeSet, Bundle)
Obsolete.

This method was deprecated in API level 15.

OnInflate(Activity, IAttributeSet, Bundle)
Obsolete.

This method was deprecated in API level 23.

OnInflate(Context, IAttributeSet, Bundle)

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.

OnInflate(IAttributeSet, Bundle)

Caution

deprecated

This method was deprecated in API level 15.

[Android.Runtime.Register("onInflate", "(Landroid/util/AttributeSet;Landroid/os/Bundle;)V", "GetOnInflate_Landroid_util_AttributeSet_Landroid_os_Bundle_Handler")]
[System.Obsolete("deprecated")]
public virtual void OnInflate(Android.Util.IAttributeSet? attrs, Android.OS.Bundle? savedInstanceState);
[<Android.Runtime.Register("onInflate", "(Landroid/util/AttributeSet;Landroid/os/Bundle;)V", "GetOnInflate_Landroid_util_AttributeSet_Landroid_os_Bundle_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member OnInflate : Android.Util.IAttributeSet * Android.OS.Bundle -> unit
override this.OnInflate : Android.Util.IAttributeSet * Android.OS.Bundle -> unit

Parameters

attrs
IAttributeSet

AttributeSet

savedInstanceState
Bundle

Bundle

Attributes

Remarks

This method was deprecated in API level 15. Use onInflate(Context,AttributeSet,Bundle) instead.

If you override this method you must call through to the superclass implementation.

Android reference for android.app.Fragment.onInflate.

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

OnInflate(Activity, IAttributeSet, Bundle)

Caution

deprecated

This method was deprecated in API level 23.

[Android.Runtime.Register("onInflate", "(Landroid/app/Activity;Landroid/util/AttributeSet;Landroid/os/Bundle;)V", "GetOnInflate_Landroid_app_Activity_Landroid_util_AttributeSet_Landroid_os_Bundle_Handler")]
[System.Obsolete("deprecated")]
public virtual void OnInflate(Android.App.Activity? activity, Android.Util.IAttributeSet? attrs, Android.OS.Bundle? savedInstanceState);
[<Android.Runtime.Register("onInflate", "(Landroid/app/Activity;Landroid/util/AttributeSet;Landroid/os/Bundle;)V", "GetOnInflate_Landroid_app_Activity_Landroid_util_AttributeSet_Landroid_os_Bundle_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member OnInflate : Android.App.Activity * Android.Util.IAttributeSet * Android.OS.Bundle -> unit
override this.OnInflate : Android.App.Activity * Android.Util.IAttributeSet * Android.OS.Bundle -> unit

Parameters

activity
Activity

Activity

attrs
IAttributeSet

AttributeSet

savedInstanceState
Bundle

Bundle

Attributes

Remarks

This method was deprecated in API level 23. Use onInflate(Context,AttributeSet,Bundle) instead.

If you override this method you must call through to the superclass implementation.

Android reference for android.app.Fragment.onInflate.

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

OnInflate(Context, IAttributeSet, Bundle)

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.

[Android.Runtime.Register("onInflate", "(Landroid/content/Context;Landroid/util/AttributeSet;Landroid/os/Bundle;)V", "GetOnInflate_Landroid_content_Context_Landroid_util_AttributeSet_Landroid_os_Bundle_Handler", ApiSince=23)]
public virtual void OnInflate(Android.Content.Context? context, Android.Util.IAttributeSet? attrs, Android.OS.Bundle? savedInstanceState);
[<Android.Runtime.Register("onInflate", "(Landroid/content/Context;Landroid/util/AttributeSet;Landroid/os/Bundle;)V", "GetOnInflate_Landroid_content_Context_Landroid_util_AttributeSet_Landroid_os_Bundle_Handler", ApiSince=23)>]
abstract member OnInflate : Android.Content.Context * Android.Util.IAttributeSet * Android.OS.Bundle -> unit
override this.OnInflate : Android.Content.Context * Android.Util.IAttributeSet * Android.OS.Bundle -> unit

Parameters

context
Context

The Context that is inflating this fragment.

attrs
IAttributeSet

The attributes at the tag where the fragment is being created.

savedInstanceState
Bundle

If the fragment is being re-created from a previous saved state, this is the state.

Attributes

Remarks

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity. This may be called immediately after the fragment is created from a tag in a layout file. Note this is before the fragment's onAttach(Activity) has been called; all you should do here is parse the attributes and save them away. This is called every time the fragment is inflated, even if it is being inflated into a new instance with saved state. It typically makes sense to re-parse the parameters each time, to allow them to change with different configurations.

Here is a typical implementation of a fragment that can take parameters both through attributes supplied here as well from getArguments():

Note that parsing the XML attributes uses a "styleable" resource. The declaration for the styleable used here is:

The fragment can then be declared within its activity's content layout through a tag like this:

This fragment can also be created dynamically from arguments given at runtime in the arguments Bundle; here is an example of doing so at creation of the containing activity:

Android reference for android.app.Fragment.onInflate.

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