material-components / material-components/material-components-android
TextInputEditText has no valueAttrChanged for compiling twoWayDatabinding
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:** I can't use two way data binding with TextInputEditText when using a MutableLiveData
Getting "Could not find event 'valueAttrChanged' on View type 'com.google.android.material.textfield.TextInputEditText'"
**Expected behavior:** I don't understand why that would be intended. If it is, how should I work around this issue?
**Source code:**
```
//ViewModel
var amount = MutableLiveData()
//Adapters
@BindingAdapter("value")
fun setVal(editText: EditText, newVal: Double) {
val currentValue = editText.text.toString()
try {
if (currentValue.isNotEmpty()) {
if (java.lang.Double.valueOf(currentValue) != newVal) {
val decimalFormat = DecimalFormat("#.##")
val value: String = decimalFormat.format(newVal)
editText.append("$value")
}
}
} catch (exception: Exception) { //
Timber.i(exception)// Do nothing
}
}
@InverseBindingAdapter(attribute = "value")
fun getVal(editText: EditText) : Double {
val currentValue = editText.text.toString()
return currentValue.toDouble()
}`
//XML
`
`
```
**Android API version:** 3.6.1
**Material Library version:** 1.1.0
**Device:** Pixel API 29
Thank you in advance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names TextInputEditText, a custom value BindingAdapter, an InverseBindingAdapter, and app:value two-way binding, but no repository files or tests. Start by reproducing the valueAttrChanged compilation error with Android API 29 and Material Library 1.1.0, then inspect the component's data-binding integration. Done means confirming the supported behavior and documenting or testing the resulting fix or workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100