我正在使用NumberPicker实现一个“轮选择器”,如this SO answer中所解释的那样。
我还使用数据绑定,并试图在XML上填充视图。
以下是我所做的:
@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"/>尽管如此,我得到:error: attribute maxValue (aka com.company.project.dev:maxValue) not found
我做错了什么?
发布于 2019-05-07 13:15:25
我用的是app:maxValue="2“
这不是一个绑定表达式。即使您的值是常量,也需要将其放在绑定表达式中:
app:maxValue="@{2}"https://stackoverflow.com/questions/56022784
复制相似问题