[英]msg:Cannot find the getter for attribute 'android:text' with value type java.lang.String in data binding?
I am trying to use data binding in the edittext, In the morning it is working fine but suddenly got the error: 我试图在edittext中使用数据绑定,在早上它工作正常,但突然得到错误:
****/ data binding error ****msg:Cannot find the getter for attribute 'android:text' with value type java.lang.String on android.widget.EditText. file:/home/itstym/ApkProjects/Reminder/app/src/main/res/layout/activity_main.xml loc:20:4 - 34:40 ****\ data binding error ****
EditText at line 20:4 -34:40 EditText在第20行:4-34:40
<EditText
app:error="@{login.errorEmail}"
android:text="@={login.userEmailAddress}"
android:hint="Email Address"
android:id="@+id/email_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="24dp"/>
View Holder: 查看持有人:
@Bindable
var userEmailAddress:String = String()
set(userEmailAddress){
field=userEmailAddress
notifyPropertyChanged(R.id.email_address)
/*to check Email for validation on every character inserted by user*/
notifyPropertyChanged(BR.errorEmail)
}
get() {
return field
}
What went suddenly wrong? 什么突然错了?
Solution tried: 1. Invalidate cache and restart. 尝试解决方案:1。使缓存无效并重新启动。 2. Clean project and Rebuild project. 2.清理项目和重建项目。
从userEmailAddress中删除get()方法,因为Kotlin在其中提供了Synthetic属性访问,你可以直接访问userEmailAddress而不用get()
I'd like to bring the answer from another post here (courtesy of Matej Drobnič) : 我想在这里提出另一篇文章的答案 (由MatejDrobnič提供):
"I just had that issue and I have managed to solve it by deleting .idea, .gradle and gradle folders and let Android Studio recreate whole project from scratch from gradle files." “我刚刚遇到了这个问题,我设法通过删除.idea,.gradle和gradle文件夹来解决它,让Android Studio从gradle文件中重新创建整个项目。”
I have run into this problem many times. 我多次遇到这个问题。 It always involves some cleaning, deleting, restarting. 它总是涉及一些清理,删除,重新启动。 For me, this answer is probably the most reliable way to remedy this flaw of Android Studio. 对我来说,这个答案可能是解决Android Studio这个缺陷最可靠的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.