I'm implementing a "Wheel picker" using NumberPicker
as explained in this SO answer.
I'm also using data binding and trying to populate the view at the XML.
Here is what I've done:
@BindingAdapter("maxValue")
internal fun NumberPicker.customSetMaxValue(max: Int){
maxValue = max
}
@BindingAdapter("minValue")
internal fun NumberPicker.customSetMinValue(min: Int){
minValue = min
}
@BindingAdapter("values")
internal fun NumberPicker.customSetDisplayedValues(data: List<String>){
displayedValues = data.toTypedArray()
}
<NumberPicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/dosage_type"
app:maxValue="2"/>
Despite of this, I get: error: attribute maxValue (aka com.company.project.dev:maxValue) not found
What am I doing wrong?
I'm using app:maxValue="2"
That is not a binding expression. Even if your value is a constant, you need to have it be in a binding expression:
app:maxValue="@{2}"