Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/view/LayoutInflater#nestedclasses) \| [Protected Ctors](https://developer.android.com/reference/android/view/LayoutInflater#proctors) \| [Methods](https://developer.android.com/reference/android/view/LayoutInflater#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/view/LayoutInflater#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/LayoutInflater#inhmethods)

# LayoutInflater

*** ** * ** ***

` public abstract class LayoutInflater `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.LayoutInflater |

<br />

*** ** * ** ***

Instantiates a layout XML file into its corresponding `https://developer.android.com/reference/android/view/View` objects. It is never used directly. Instead, use `https://developer.android.com/reference/android/app/Activity#getLayoutInflater()` or `https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.Class<T>)` 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.

To create a new LayoutInflater with an additional `https://developer.android.com/reference/android/view/LayoutInflater.Factory` for your own views, you can use `https://developer.android.com/reference/android/view/LayoutInflater#cloneInContext(android.content.Context)` to clone an existing ViewFactory, and then call `https://developer.android.com/reference/android/view/LayoutInflater#setFactory(android.view.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.)

**Note:** This class is **not** thread-safe and a given instance should only be accessed by a single thread.

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/android/view/LayoutInflater.Factory` |
| ` interface` | `https://developer.android.com/reference/android/view/LayoutInflater.Factory2` |
| ` interface` | `https://developer.android.com/reference/android/view/LayoutInflater.Filter` Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated. |

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/LayoutInflater#LayoutInflater(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Create a new LayoutInflater instance associated with a particular Context. |
| ` https://developer.android.com/reference/android/view/LayoutInflater#LayoutInflater(android.view.LayoutInflater,%20android.content.Context)(https://developer.android.com/reference/android/view/LayoutInflater original, https://developer.android.com/reference/android/content/Context newContext) ` Create a new LayoutInflater instance that is a copy of an existing LayoutInflater, optionally with its Context changed. |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/view/LayoutInflater` | ` https://developer.android.com/reference/android/view/LayoutInflater#cloneInContext(android.content.Context)(https://developer.android.com/reference/android/content/Context newContext) ` Create a copy of the existing LayoutInflater object, with the copy pointing to a different Context than the original. |
| ` final https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#createView(android.content.Context,%20java.lang.String,%20java.lang.String,%20android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context viewContext, https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/lang/String prefix, https://developer.android.com/reference/android/util/AttributeSet attrs) ` Low-level function for instantiating a view by name. |
| ` final https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#createView(java.lang.String,%20java.lang.String,%20android.util.AttributeSet)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/lang/String prefix, https://developer.android.com/reference/android/util/AttributeSet attrs) ` Low-level function for instantiating a view by name. |
| ` static https://developer.android.com/reference/android/view/LayoutInflater` | ` https://developer.android.com/reference/android/view/LayoutInflater#from(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Obtains the LayoutInflater from the given context. |
| ` https://developer.android.com/reference/android/content/Context` | ` https://developer.android.com/reference/android/view/LayoutInflater#getContext()() ` Return the context we are running in, for access to resources, class loader, etc. |
| ` final https://developer.android.com/reference/android/view/LayoutInflater.Factory` | ` https://developer.android.com/reference/android/view/LayoutInflater#getFactory()() ` Return the current `https://developer.android.com/reference/android/view/LayoutInflater.Factory` (or null). |
| ` final https://developer.android.com/reference/android/view/LayoutInflater.Factory2` | ` https://developer.android.com/reference/android/view/LayoutInflater#getFactory2()() ` Return the current `https://developer.android.com/reference/android/view/LayoutInflater.Factory2`. |
| ` https://developer.android.com/reference/android/view/LayoutInflater.Filter` | ` https://developer.android.com/reference/android/view/LayoutInflater#getFilter()() ` |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#inflate(int,%20android.view.ViewGroup)(int resource, https://developer.android.com/reference/android/view/ViewGroup root) ` Inflate a new view hierarchy from the specified xml resource. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#inflate(org.xmlpull.v1.XmlPullParser,%20android.view.ViewGroup)(https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser parser, https://developer.android.com/reference/android/view/ViewGroup root) ` Inflate a new view hierarchy from the specified xml node. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#inflate(org.xmlpull.v1.XmlPullParser,%20android.view.ViewGroup,%20boolean)(https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser parser, https://developer.android.com/reference/android/view/ViewGroup root, boolean attachToRoot) ` Inflate a new view hierarchy from the specified XML node. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#inflate(int,%20android.view.ViewGroup,%20boolean)(int resource, https://developer.android.com/reference/android/view/ViewGroup root, boolean attachToRoot) ` Inflate a new view hierarchy from the specified xml resource. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(android.content.Context,%20android.view.View,%20java.lang.String,%20android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context viewContext, https://developer.android.com/reference/android/view/View parent, https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/android/util/AttributeSet attrs) ` Version of `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(android.view.View,%20java.lang.String,%20android.util.AttributeSet)` that also takes the inflation context. |
| ` void` | ` https://developer.android.com/reference/android/view/LayoutInflater#setFactory(android.view.LayoutInflater.Factory)(https://developer.android.com/reference/android/view/LayoutInflater.Factory factory) ` Attach a custom Factory interface for creating views while using this LayoutInflater. |
| ` void` | ` https://developer.android.com/reference/android/view/LayoutInflater#setFactory2(android.view.LayoutInflater.Factory2)(https://developer.android.com/reference/android/view/LayoutInflater.Factory2 factory) ` Like `https://developer.android.com/reference/android/view/LayoutInflater#setFactory(android.view.LayoutInflater.Factory)`, but allows you to set a `https://developer.android.com/reference/android/view/LayoutInflater.Factory2` interface. |
| ` void` | ` https://developer.android.com/reference/android/view/LayoutInflater#setFilter(android.view.LayoutInflater.Filter)(https://developer.android.com/reference/android/view/LayoutInflater.Filter filter) ` Sets the `https://developer.android.com/reference/android/view/LayoutInflater.Filter` to by this LayoutInflater. |

| ### Protected methods ||
|---|---|
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(android.view.View,%20java.lang.String,%20android.util.AttributeSet)(https://developer.android.com/reference/android/view/View parent, https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/android/util/AttributeSet attrs) ` Version of `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(java.lang.String,%20android.util.AttributeSet)` that also takes the future parent of the view being constructed. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(java.lang.String,%20android.util.AttributeSet)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/android/util/AttributeSet attrs) ` This routine is responsible for creating the correct subclass of View given the xml element name. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Protected constructors

### LayoutInflater

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected LayoutInflater (Context context)
```

Create a new LayoutInflater instance associated with a particular Context. Applications will almost always want to use `https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.Class<T>)` to retrieve the standard `https://developer.android.com/reference/android/content/Context#LAYOUT_INFLATER_SERVICE`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The Context in which this LayoutInflater will create its Views; most importantly, this supplies the theme from which the default values for their attributes are retrieved. <br /> |

### LayoutInflater

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected LayoutInflater (LayoutInflater original, 
                Context newContext)
```

Create a new LayoutInflater instance that is a copy of an existing LayoutInflater, optionally with its Context changed. For use in implementing `https://developer.android.com/reference/android/view/LayoutInflater#cloneInContext(android.content.Context)`.

<br />

| Parameters ||
|---|---|
| `original` | `LayoutInflater`: The original LayoutInflater to copy. <br /> |
| `newContext` | `Context`: The new Context to use. <br /> |

## Public methods

### cloneInContext

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract LayoutInflater cloneInContext (Context newContext)
```

Create a copy of the existing LayoutInflater object, with the copy pointing to a different Context than the original. This is used by `https://developer.android.com/reference/android/view/ContextThemeWrapper` to create a new LayoutInflater to go along with the new Context theme.

<br />

| Parameters ||
|---|---|
| `newContext` | `Context`: The new Context to associate with the new LayoutInflater. May be the same as the original Context if desired. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater` | Returns a brand spanking new LayoutInflater object associated with the given Context. <br /> |

### createView

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final View createView (Context viewContext, 
                String name, 
                String prefix, 
                AttributeSet attrs)
```

Low-level function for instantiating a view by name. This attempts to instantiate a view class of the given <var translate="no">name</var> found in this LayoutInflater's ClassLoader.

There are two things that can happen in an error case: either the exception describing the error will be thrown, or a null will be returned. You must deal with both possibilities -- the former will happen the first time createView() is called for a class of a particular name, the latter every time there-after for that class name.

<br />

| Parameters ||
|---|---|
| `viewContext` | `Context`: The context used as the context parameter of the View constructor. This value cannot be `null`. <br /> |
| `name` | `String`: The full name of the class to be instantiated. This value cannot be `null`. <br /> |
| `prefix` | `String`: This value may be `null`. <br /> |
| `attrs` | `AttributeSet`: The XML attributes supplied for this instance. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | View The newly instantiated view, or null. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassNotFoundException` |   |
| `https://developer.android.com/reference/android/view/InflateException` |   |

### createView

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final View createView (String name, 
                String prefix, 
                AttributeSet attrs)
```

Low-level function for instantiating a view by name. This attempts to instantiate a view class of the given <var translate="no">name</var> found in this LayoutInflater's ClassLoader. To use an explicit Context in the View constructor, use `https://developer.android.com/reference/android/view/LayoutInflater#createView(android.content.Context,%20java.lang.String,%20java.lang.String,%20android.util.AttributeSet)` instead.

There are two things that can happen in an error case: either the exception describing the error will be thrown, or a null will be returned. You must deal with both possibilities -- the former will happen the first time createView() is called for a class of a particular name, the latter every time there-after for that class name.

<br />

| Parameters ||
|---|---|
| `name` | `String`: The full name of the class to be instantiated. <br /> |
| `prefix` | `String` <br /> |
| `attrs` | `AttributeSet`: The XML attributes supplied for this instance. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | View The newly instantiated view, or null. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassNotFoundException` |   |
| `https://developer.android.com/reference/android/view/InflateException` |   |

### from

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static LayoutInflater from (Context context)
```

Obtains the LayoutInflater from the given context.

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater` | <br /> |

### getContext

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Context getContext ()
```

Return the context we are running in, for access to resources, class loader, etc.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/Context` | <br /> |

### getFactory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final LayoutInflater.Factory getFactory ()
```

Return the current `https://developer.android.com/reference/android/view/LayoutInflater.Factory` (or null). This is called on each element name. If the factory returns a View, add that to the hierarchy. If it returns null, proceed to call onCreateView(name).

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater.Factory` | <br /> |

### getFactory2

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final LayoutInflater.Factory2 getFactory2 ()
```

Return the current `https://developer.android.com/reference/android/view/LayoutInflater.Factory2`. Returns null if no factory is set or the set factory does not implement the `https://developer.android.com/reference/android/view/LayoutInflater.Factory2` interface. This is called on each element name. If the factory returns a View, add that to the hierarchy. If it returns null, proceed to call onCreateView(name).

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater.Factory2` | <br /> |

### getFilter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public LayoutInflater.Filter getFilter ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater.Filter` | The `https://developer.android.com/reference/android/view/LayoutInflater.Filter` currently used by this LayoutInflater to restrict the set of Views that are allowed to be inflated. <br /> |

### inflate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View inflate (int resource, 
                ViewGroup root)
```

Inflate a new view hierarchy from the specified xml resource. Throws `https://developer.android.com/reference/android/view/InflateException` if there is an error.

<br />

| Parameters ||
|---|---|
| `resource` | `int`: ID for an XML layout resource to load (e.g., `R.layout.main_page`) <br /> |
| `root` | `ViewGroup`: Optional view to be the parent of the generated hierarchy. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The root View of the inflated hierarchy. If root was supplied, this is the root View; otherwise it is the root of the inflated XML file. <br /> |

### inflate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View inflate (XmlPullParser parser, 
                ViewGroup root)
```

Inflate a new view hierarchy from the specified xml node. Throws `https://developer.android.com/reference/android/view/InflateException` if there is an error. \*

***Important*** 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.

<br />

| Parameters ||
|---|---|
| `parser` | `XmlPullParser`: XML dom node containing the description of the view hierarchy. <br /> |
| `root` | `ViewGroup`: Optional view to be the parent of the generated hierarchy. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The root View of the inflated hierarchy. If root was supplied, this is the root View; otherwise it is the root of the inflated XML file. <br /> |

### inflate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View inflate (XmlPullParser parser, 
                ViewGroup root, 
                boolean attachToRoot)
```

Inflate a new view hierarchy from the specified XML node. Throws `https://developer.android.com/reference/android/view/InflateException` if there is an error.

***Important*** 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.

<br />

| Parameters ||
|---|---|
| `parser` | `XmlPullParser`: XML dom node containing the description of the view hierarchy. <br /> |
| `root` | `ViewGroup`: Optional view to be the parent of the generated hierarchy (if *attachToRoot* is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if *attachToRoot* is false.). This value may be `null`. <br /> |
| `attachToRoot` | `boolean`: Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The root View of the inflated hierarchy. If root was supplied and attachToRoot is true, this is root; otherwise it is the root of the inflated XML file. <br /> |

### inflate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View inflate (int resource, 
                ViewGroup root, 
                boolean attachToRoot)
```

Inflate a new view hierarchy from the specified xml resource. Throws `https://developer.android.com/reference/android/view/InflateException` if there is an error.

<br />

| Parameters ||
|---|---|
| `resource` | `int`: ID for an XML layout resource to load (e.g., `R.layout.main_page`) <br /> |
| `root` | `ViewGroup`: Optional view to be the parent of the generated hierarchy (if *attachToRoot* is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if *attachToRoot* is false.). This value may be `null`. <br /> |
| `attachToRoot` | `boolean`: Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The root View of the inflated hierarchy. If root was supplied and attachToRoot is true, this is root; otherwise it is the root of the inflated XML file. <br /> |

### onCreateView

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View onCreateView (Context viewContext, 
                View parent, 
                String name, 
                AttributeSet attrs)
```

Version of `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(android.view.View,%20java.lang.String,%20android.util.AttributeSet)` that also takes the inflation context. The default implementation simply calls `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(android.view.View,%20java.lang.String,%20android.util.AttributeSet)`.

<br />

| Parameters ||
|---|---|
| `viewContext` | `Context`: The Context to be used as a constructor parameter for the View. This value cannot be `null`. <br /> |
| `parent` | `View`: The future parent of the returned view. *Note that this may be null.* <br /> |
| `name` | `String`: The fully qualified class name of the View to be create. This value cannot be `null`. <br /> |
| `attrs` | `AttributeSet`: An AttributeSet of attributes to apply to the View. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | View The View created. This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassNotFoundException` |   |

### setFactory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setFactory (LayoutInflater.Factory factory)
```

Attach a custom Factory interface for creating views while using this LayoutInflater. This must not be null, and can only be set once; after setting, you can not change the factory. This is called on each element name as the xml is parsed. If the factory returns a View, that is added to the hierarchy. If it returns null, the next factory default `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(android.content.Context,%20android.view.View,%20java.lang.String,%20android.util.AttributeSet)` method is called.

If you have an existing LayoutInflater and want to add your own factory to it, use `https://developer.android.com/reference/android/view/LayoutInflater#cloneInContext(android.content.Context)` to clone the existing instance and then you can use this function (once) on the returned new instance. This will merge your own factory with whatever factory the original instance is using.

<br />

| Parameters ||
|---|---|
| `factory` | `LayoutInflater.Factory` <br /> |

### setFactory2

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setFactory2 (LayoutInflater.Factory2 factory)
```

Like `https://developer.android.com/reference/android/view/LayoutInflater#setFactory(android.view.LayoutInflater.Factory)`, but allows you to set a `https://developer.android.com/reference/android/view/LayoutInflater.Factory2` interface.

<br />

| Parameters ||
|---|---|
| `factory` | `LayoutInflater.Factory2` <br /> |

### setFilter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setFilter (LayoutInflater.Filter filter)
```

Sets the `https://developer.android.com/reference/android/view/LayoutInflater.Filter` to by this LayoutInflater. If a view is attempted to be inflated which is not allowed by the `https://developer.android.com/reference/android/view/LayoutInflater.Filter`, the `https://developer.android.com/reference/android/view/LayoutInflater#inflate(int,%20android.view.ViewGroup)` call will throw an `https://developer.android.com/reference/android/view/InflateException`. This filter will replace any previous filter set on this LayoutInflater.

<br />

| Parameters ||
|---|---|
| `filter` | `LayoutInflater.Filter`: The Filter which restricts the set of Views that are allowed to be inflated. This filter will replace any previous filter set on this LayoutInflater. <br /> |

## Protected methods

### onCreateView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected View onCreateView (View parent, 
                String name, 
                AttributeSet attrs)
```

Version of `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(java.lang.String,%20android.util.AttributeSet)` that also takes the future parent of the view being constructed. The default implementation simply calls `https://developer.android.com/reference/android/view/LayoutInflater#onCreateView(java.lang.String,%20android.util.AttributeSet)`.

<br />

| Parameters ||
|---|---|
| `parent` | `View`: The future parent of the returned view. *Note that this may be null.* <br /> |
| `name` | `String`: The fully qualified class name of the View to be create. <br /> |
| `attrs` | `AttributeSet`: An AttributeSet of attributes to apply to the View. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | View The View created. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassNotFoundException` |   |

### onCreateView

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected View onCreateView (String name, 
                AttributeSet attrs)
```

This routine is responsible for creating the correct subclass of View given the xml element name. Override it to handle custom view objects. If you override this in your subclass be sure to call through to super.onCreateView(name) for names you do not recognize.

<br />

| Parameters ||
|---|---|
| `name` | `String`: The fully qualified class name of the View to be create. <br /> |
| `attrs` | `AttributeSet`: An AttributeSet of attributes to apply to the View. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | View The View created. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassNotFoundException` |   |