I'm working on an Android application built using Anvil and Kotlin, and currently I've got a RecyclerView rendering a list of key-value pairs that should be editable by the user. In order to save these edits, I've added an onTextChanged
listener as follows:
textInputLayout {
size(MATCH, WRAP)
/* ommitted style attributes */
editText {
size(MATCH, WRAP)
/* ommitted style attributes */
init {
text(getPropertyValue(item))
onTextChanged { onPropertyChange(item.first, it.toString()) }
}
}
}
In the above example, item
is of type Pair<String, Property>
where Property
is a custom object that gives information about format type (string, date, number, etc.) and the getPropertyValue
call has the signature getPropertyValue(item: Pair<String, Property>): String
.
For some reason, every time I type the text field sees no changes but loses focus. The onTextChanged
listener is definitely getting called because when it executes I can see the updated values produced by onPropertyChange
getting logged to the console.
I've already tried the solutions outlined here to no avail. Does anyone have any other suggestions? Been stuck on this for a while now.