gpt4 book ai didi

Android资源链接在绑定(bind)适配器数据绑定(bind)中失败

转载 作者:行者123 更新时间:2023-12-04 23:48:46 26 4
gpt4 key购买 nike

我想使用绑定(bind)适配器设置文本。这里是 MyBindingAdapter.kt

@BindingAdapter("android:setTitle")
fun setTitle(textView : TextView,text: String){
textView.text = text
}
在 activity_table.xml 我这样使用 setTitle
  <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_weight="1"
android:gravity="center"
android:setTitle="Hello word"/>
我在编译时遇到错误
and I getting below error at compile time

最佳答案

您需要从 @BindingAdapter("android:setTitle") 更改至@BindingAdapter("setTitle")在您的 MyBindingAdapter.kt 中。
您还需要从 android:setTitle="Hello word" 更改 xml 文件至setTitle="Hello word"它现在应该可以工作了!

关于Android资源链接在绑定(bind)适配器数据绑定(bind)中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66999911/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com