I have three `TextInputEditText` views in my layout where the user can type in specific information.  

On the click of a `Button` this information is stored in my database.

After the user clicks this `Button`, I want to clear all `TextInputEditText` fields.  

Right now, I am doing this by hardcoding:

```
private fun clearAllEditTextFields() {

    Timber.d("clearAllEditTextFields: called")

    binding.bookTitleEditText.text = null
    binding.bookAuthorEditText.text = null
    binding.bookPageCountEditText.text = null

}

```

Since this is bad, I would like to use a dynamic `for each` loop to identify all views of type `TextInputEditText` known to `binding` and clear their content:

```
private fun clearAllEditTextFields() {

    Timber.d("clearAllEditTextFields: called")

    for (view in binding.views) {

        if (view is TextInputEditText) {

            view.text = null

        }

}

```

Unfortunately, there is no such field `binding.views`.  

Is there still a way to achieve this or something with the same properties?

### What I have tried so far

I have used a `BindingAdapter`. In my `Util` class, where all my extension functions go, I have created an `EditText` extension function `clearText` annotated as `BindingAdapter` and `JvmStatic`:

```
@JvmStatic
@BindingAdapter("clearText")
fun EditText.clearText(@NotNull shouldClear: Boolean) {

    Timber.d("clearText: called")

    if (shouldClear) text = null

}

```

In XML:

```
<com.google.android.material.textfield.TextInputEditText
    android:id="@+id/book_title_edit_text"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:imeActionId="100"
    android:imeOptions="actionNext"
    android:inputType="text"
    android:text="@={viewModel.bookTitle}"
    app:clearText="@{viewModel.clearAllEditTextFields}"
/>

```

In my `ViewModel` class, I have created a `var clearAllEditTextFields = false` which is modified in the `clearAllEditTextFields()` function which gets called inside my `ViewModel`:

```
...
var clearAllEditTextFields = false
clearAllEditTextFields()
...

private fun clearAllEditTextFields() {

    Timber.d("clearAllEditTextFields: called")

    clearAllEditTextFields = true

}

```

According to Logcat, my extension function is called when my `ViewModel` is initialized. However, when `clearAllEditTextFields()` gets called, it does not trigger a new call to the extension function.