Android Guides | Samples

Android.Views.LayoutInflater Class

Instantiates a layout XML file into its corresponding View objects.

See Also: LayoutInflater

Syntax

[Android.Runtime.Register("android/view/LayoutInflater", DoNotGenerateAcw=true)]
public abstract class LayoutInflater : Object

Remarks

Instantiates a layout XML file into its corresponding View objects. It is never used directly. Instead, use Activity.LayoutInflater or Context.GetSystemService(String) to retrieve a standard LayoutInflater instance that is already hooked up to the current context and correctly configured for the device you are running on. For example:

java Example

LayoutInflater inflater = (LayoutInflater)context.getSystemService
      (Context.LAYOUT_INFLATER_SERVICE);

To create a new LayoutInflater with an additional NoType:android/view/LayoutInflater$Factory;Href=../../../reference/android/view/LayoutInflater.Factory.html for your own views, you can use LayoutInflater.CloneInContext(Context) to clone an existing ViewFactory, and then call LayoutInflater.Factory on it to include your Factory.

For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; it only works with an XmlPullParser returned from a compiled resource (R.something file.)

See Also

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Views.LayoutInflater are listed below.

See Also: Object

Protected Constructors

Create a new LayoutInflater instance associated with a particular Context.
Create a new LayoutInflater instance that is a copy of an existing LayoutInflater, optionally with its Context changed.
A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

abstract
CloneInContext(Context) : LayoutInflater
Create a copy of the existing LayoutInflater object, with the copy pointing to a different Context than the original.
CreateView(String, String, IAttributeSet) : View
Low-level function for instantiating a view by name.
static
From(Context) : LayoutInflater
Obtains the LayoutInflater from the given context.
static
FromContext(Context) : LayoutInflater
Inflate(Int32, ViewGroup) : View
Inflate a new view hierarchy from the specified xml resource.
Inflate(XmlReader, ViewGroup) : View
Inflate a new view hierarchy from the specified xml node.
Inflate(Int32, ViewGroup, Boolean) : View
Inflate a new view hierarchy from the specified xml resource.
Inflate(XmlReader, ViewGroup, Boolean) : View
Inflate a new view hierarchy from the specified XML node.

Protected Methods

OnCreateView(String, IAttributeSet) : View
This routine is responsible for creating the correct subclass of View given the xml element name.
OnCreateView(View, String, IAttributeSet) : View
Version of LayoutInflater.OnCreateView(String,IAttributeSet) that also takes the future parent of the view being constructed.