# 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)

*** ** * ** ***


```
public abstract class FragmentContainer
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/fragment/app/FragmentHostCallback` | Integration points with the Fragment host. |

*** ** * ** ***

Callbacks to a `https://developer.android.com/reference/androidx/fragment/app/Fragment`'s container.

## Summary

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

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/Fragment` | `[instantiate](https://developer.android.com/reference/androidx/fragment/app/FragmentContainer#instantiate(android.content.Context,java.lang.String,android.os.Bundle))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html arguments )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#setFragmentFactory(androidx.fragment.app.FragmentFactory)` to control how Fragments are instantiated. <br /> |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/fragment/app/FragmentContainer#onFindViewById(int)(@https://developer.android.com/reference/androidx/annotation/IdRes int id)` Return the view with the given resource ID. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/fragment/app/FragmentContainer#onHasView()()` Return `true` if the container holds any view. |

## Public constructors

### FragmentContainer

Added in 1.1.0

```
public FragmentContainer()
```

## Public methods

### 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)

```
public @NonNull Fragment [instantiate](https://developer.android.com/reference/androidx/fragment/app/FragmentContainer#instantiate(android.content.Context,java.lang.String,android.os.Bundle))(
    @NonNull Context context,
    @NonNull String className,
    @Nullable Bundle arguments
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/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 `https://developer.android.com/reference/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)

```
public abstract @Nullable View onFindViewById(@IdRes int id)
```

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)

```
public abstract boolean onHasView()
```

Return `true` if the container holds any view.