# DialogCompat

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

*** ** * ** ***


```
public class DialogCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/app/Dialog.html` in a backwards compatible fashion.

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/core/app/DialogCompat#requireViewById(android.app.Dialog,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Dialog.html dialog, int id)` Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via `https://developer.android.com/reference/android/app/Dialog.html#show()` or `https://developer.android.com/reference/android/app/Dialog.html#create()`). |

## Public methods

### requireViewById

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

```
public static @NonNull View requireViewById(@NonNull Dialog dialog, int id)
```

Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via `https://developer.android.com/reference/android/app/Dialog.html#show()` or `https://developer.android.com/reference/android/app/Dialog.html#create()`).

**Note:** In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Dialog.html dialog` | the Dialog to search the View in |
| `int id` | the ID to search for |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html` | a view with given ID |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#requireViewById(int)` |   |
| `https://developer.android.com/reference/android/app/Dialog.html#requireViewById(int)` |   |
| `https://developer.android.com/reference/android/app/Dialog.html#findViewById(int)` |   |