# LayoutInflater.Factory2

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/view/LayoutInflater.Factory2#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/view/LayoutInflater.Factory2#inhmethods)  

# LayoutInflater.Factory2

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/LayoutInflater.Factory2 "View this page in Kotlin")\|Java

`
public
static


interface
LayoutInflater.Factory2
`  
`


implements

`[LayoutInflater.Factory](https://developer.android.com/reference/android/view/LayoutInflater.Factory)`


`

|--------------------------------------|
| android.view.LayoutInflater.Factory2 |

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [AccountAuthenticatorActivity](https://developer.android.com/reference/android/accounts/AccountAuthenticatorActivity),[Activity](https://developer.android.com/reference/android/app/Activity),[ActivityGroup](https://developer.android.com/reference/android/app/ActivityGroup),[AliasActivity](https://developer.android.com/reference/android/app/AliasActivity),[ExpandableListActivity](https://developer.android.com/reference/android/app/ExpandableListActivity),[LauncherActivity](https://developer.android.com/reference/android/app/LauncherActivity),[ListActivity](https://developer.android.com/reference/android/app/ListActivity),[NativeActivity](https://developer.android.com/reference/android/app/NativeActivity),[PreferenceActivity](https://developer.android.com/reference/android/preference/PreferenceActivity),[TabActivity](https://developer.android.com/reference/android/app/TabActivity) |-----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AccountAuthenticatorActivity](https://developer.android.com/reference/android/accounts/AccountAuthenticatorActivity) | *This class was deprecated in API level 30. Applications should extend Activity themselves. This class is not compatible with AppCompat, and the functionality it provides is not complex.*                                                                                                                                                                                                     | | [Activity](https://developer.android.com/reference/android/app/Activity)                                              | An activity is a single, focused thing that the user can do.                                                                                                                                                                                                                                                                                                                                    | | [ActivityGroup](https://developer.android.com/reference/android/app/ActivityGroup)                                    | *This class was deprecated in API level 13. Use the new[Fragment](https://developer.android.com/reference/android/app/Fragment)and[FragmentManager](https://developer.android.com/reference/android/app/FragmentManager)APIs instead; these are also available on older platforms through the Android compatibility package.*                                                                   | | [AliasActivity](https://developer.android.com/reference/android/app/AliasActivity)                                    | *This class was deprecated in API level 30. Use`<activity-alias>`or subclass Activity directly.*                                                                                                                                                                                                                                                                                                | | [ExpandableListActivity](https://developer.android.com/reference/android/app/ExpandableListActivity)                  | *This class was deprecated in API level 30. Use[RecyclerView](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.html)or use[ExpandableListView](https://developer.android.com/reference/android/widget/ExpandableListView)directly*                                                                                                                             | | [LauncherActivity](https://developer.android.com/reference/android/app/LauncherActivity)                              | *This class was deprecated in API level 30. Applications can implement this UI themselves using[RecyclerView](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.html)and[PackageManager.queryIntentActivities(Intent, int)](https://developer.android.com/reference/android/content/pm/PackageManager#queryIntentActivities(android.content.Intent,%20int))*    | | [ListActivity](https://developer.android.com/reference/android/app/ListActivity)                                      | *This class was deprecated in API level 30. Use[ListFragment](https://developer.android.com/reference/androidx/fragment/app/ListFragment.html)or[RecyclerView](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.html)to implement your Activity instead.*                                                                                                      | | [NativeActivity](https://developer.android.com/reference/android/app/NativeActivity)                                  | Convenience for implementing an activity that will be implemented purely in native code.                                                                                                                                                                                                                                                                                                        | | [PreferenceActivity](https://developer.android.com/reference/android/preference/PreferenceActivity)                   | *This class was deprecated in API level 29. Use the[AndroidX](https://developer.android.com/jetpack/androidx)[Preference Library](https://developer.android.com/reference/androidx/preference/package-summary)for consistent behavior across all devices. For more information on using the AndroidX Preference Library see[Settings](https://developer.android.com/guide/topics/ui/settings).* | | [TabActivity](https://developer.android.com/reference/android/app/TabActivity)                                        | *This class was deprecated in API level 13. New applications should use Fragments instead of this class; to continue to run on older devices, you can use the v4 support library which provides a version of the Fragment API that is compatible down to[Build.VERSION_CODES.DONUT](https://developer.android.com/reference/android/os/Build.VERSION_CODES#DONUT).*                             | |

<br />

*** ** * ** ***

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ||
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[View](https://developer.android.com/reference/android/view/View) | ` `[onCreateView](https://developer.android.com/reference/android/view/LayoutInflater.Factory2#onCreateView(android.view.View,%20java.lang.String,%20android.content.Context,%20android.util.AttributeSet))`(`[View](https://developer.android.com/reference/android/view/View)` parent, `[String](https://developer.android.com/reference/java/lang/String)` name, `[Context](https://developer.android.com/reference/android/content/Context)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet)` attrs) ` Version of[LayoutInflater.Factory.onCreateView(java.lang.String, android.content.Context, android.util.AttributeSet)](https://developer.android.com/reference/android/view/LayoutInflater.Factory#onCreateView(java.lang.String,%20android.content.Context,%20android.util.AttributeSet))that also supplies the parent that the view created view will be placed in. |

| ### Inherited methods |
|-----------------------|---|
| From interface` `[android.view.LayoutInflater.Factory](https://developer.android.com/reference/android/view/LayoutInflater.Factory)` ` |-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[View](https://developer.android.com/reference/android/view/View) | ` `[onCreateView](https://developer.android.com/reference/android/view/LayoutInflater.Factory#onCreateView(java.lang.String,%20android.content.Context,%20android.util.AttributeSet))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[Context](https://developer.android.com/reference/android/content/Context)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet)` attrs) ` Hook you can supply that is called when inflating from a LayoutInflater. | ||

## Public methods

### onCreateView

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

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

Version of[LayoutInflater.Factory.onCreateView(java.lang.String, android.content.Context, android.util.AttributeSet)](https://developer.android.com/reference/android/view/LayoutInflater.Factory#onCreateView(java.lang.String,%20android.content.Context,%20android.util.AttributeSet))that also supplies the parent that the view created view will be placed in.

<br />

|                                                  Parameters                                                  ||
|-----------|---------------------------------------------------------------------------------------------------|
| `parent`  | `View`: The parent that the created view will be placed in;*note that this may be null* . <br />  |
| `name`    | `String`: Tag name to be inflated. This value cannot be`null`. <br />                             |
| `context` | `Context`: The context the view is being created in. This value cannot be`null`. <br />           |
| `attrs`   | `AttributeSet`: Inflation attributes as specified in XML file. This value cannot be`null`. <br /> |

|                                                                 Returns                                                                  ||
|-------------------------------------------------------------------|-----------------------------------------------------------------------|
| [View](https://developer.android.com/reference/android/view/View) | View Newly created view. Return null for the default behavior. <br /> |