# FragmentContainer

# FragmentContainer

Artifact:[androidx.fragment:fragment](https://developer.android.com/jetpack/androidx/releases/fragment)  
[View Source](https://cs.android.com/search?q=file:androidx/fragment/app/FragmentContainer.java+class:androidx.fragment.app.FragmentContainer)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/fragment/app/FragmentContainer "View this page in Java")

<br />

```
abstract class FragmentContainer
```

<br />

Known direct subclasses  
[FragmentHostCallback](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentHostCallback)  

|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| [FragmentHostCallback](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentHostCallback) | Integration points with the Fragment host. |

*** ** * ** ***

Callbacks to a[Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment)'s container.

## Summary

|                                                       ### Public constructors                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------|
| [FragmentContainer](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentContainer#FragmentContainer())`()` |

|                                      ### Public functions                                      |
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment)      | ~~[instantiate](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentContainer#instantiate(android.content.Context,java.lang.String,android.os.Bundle))~~`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, arguments: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`?)` **This function is deprecated.** Use[setFragmentFactory](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentManager#setFragmentFactory(androidx.fragment.app.FragmentFactory))to control how Fragments are instantiated. <br /> |
| `abstract `[View](https://developer.android.com/reference/android/view/View.html)`?`           | [onFindViewById](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentContainer#onFindViewById(int))`(id: @`[IdRes](https://developer.android.com/reference/kotlin/androidx/annotation/IdRes)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Return the view with the given resource ID.                                                                                                                                                                                                                                                                                                                                                                                |
| `abstract `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [onHasView](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentContainer#onHasView())`()` Return`true`if the container holds any view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Public constructors

### FragmentContainer

Added in 1.1.0  

```
FragmentContainer()
```  

## Public functions

### instantiate

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)  

```
fun [instantiate](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentContainer#instantiate(android.content.Context,java.lang.String,android.os.Bundle))(context: Context, className: String, arguments: Bundle?): Fragment
```
| **This function is deprecated.**   
|
| Use[setFragmentFactory](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentManager#setFragmentFactory(androidx.fragment.app.FragmentFactory))to control how Fragments are instantiated.

Creates an instance of the specified fragment, can be overridden to construct fragments with dependencies, or change the fragment being constructed. By default just calls[instantiate](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment#instantiate(android.content.Context,java.lang.String,android.os.Bundle)).  

### onFindViewById

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)  

```
abstract fun onFindViewById(id: @IdRes Int): View?
```

Return the view with the given resource ID. May return`null`if the view is not a child of this container.  

### onHasView

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)  

```
abstract fun onHasView(): Boolean
```

Return`true`if the container holds any view.