# ViewKt

Added in 1.9.1

*** ** * ** ***


```
public final class ViewKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull F` | `<F extends https://developer.android.com/reference/androidx/fragment/app/Fragment> https://developer.android.com/reference/androidx/fragment/app/ViewKt#(android.view.View).findFragment()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Find a `https://developer.android.com/reference/androidx/fragment/app/Fragment` associated with a `https://developer.android.com/reference/android/view/View.html`. |

## Public methods

### findFragment

Artifact: [androidx.fragment:fragment](https://developer.android.com/jetpack/androidx/releases/fragment) [View Source](https://cs.android.com/search?q=file:androidx/fragment/app/View.kt+function:findFragment) Added in [1.9.1](https://developer.android.com/jetpack/androidx/releases/fragment#1.9.1)

```
public static final @NonNull F <F extends Fragment> findFragment(@NonNull View receiver)
```

Find a `https://developer.android.com/reference/androidx/fragment/app/Fragment` associated with a `https://developer.android.com/reference/android/view/View.html`.

This method will locate the `https://developer.android.com/reference/androidx/fragment/app/Fragment` associated with this view. This is automatically populated for the View returned by `https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateView(android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle)` and its children.

Calling this on a View that does not have a Fragment set will result in an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html`