# DialogCompat

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

*** ** * ** ***

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

<br />

```
class DialogCompat
```

<br />

*** ** * ** ***

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

## Summary

|                                 ### Public functions                                 |
|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[View](https://developer.android.com/reference/android/view/View.html) | [requireViewById](https://developer.android.com/reference/kotlin/androidx/core/app/DialogCompat#requireViewById(android.app.Dialog,int))`(dialog: `[Dialog](https://developer.android.com/reference/android/app/Dialog.html)`, id: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` 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[show](https://developer.android.com/reference/android/app/Dialog.html#show())or[create](https://developer.android.com/reference/android/app/Dialog.html#create())). |

## Public functions

### requireViewById

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

```
java-static fun requireViewById(dialog: Dialog, id: Int): View
```

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[show](https://developer.android.com/reference/android/app/Dialog.html#show())or[create](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                                      |
|-------------------------------------------------------------------------------------|----------------------------------|
| `dialog: `[Dialog](https://developer.android.com/reference/android/app/Dialog.html) | the Dialog to search the View in |
| `id: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | the ID to search for             |

|                                Returns                                 |
|------------------------------------------------------------------------|----------------------|
| [View](https://developer.android.com/reference/android/view/View.html) | a view with given ID |

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