android studio无法创建ActivityRegisterBindingImpl

问题描述 投票:0回答:1

嗨当我尝试重建和运行我的项目时,面对这个错误:

Found data binding errors.

****/ data binding error ****msg:Identifiers must have user defined types from the XML file. LoginViewModel is missing it file:/home/ramtin/Desktop/QuestionAndAnswer/app/src/main/res/layout/activity_register.xml loc:32:33 - 32:46 ****\ data binding error ****

RegisterViewModel类:

public class RegisterViewModel extends ViewModel {
    public MutableLiveData<String> name = new MutableLiveData<>();
    public MutableLiveData<String> EmailAddress = new MutableLiveData<>();
    public MutableLiveData<String> Password = new MutableLiveData<>();

private MutableLiveData<RegisterUser> currentName;

public MutableLiveData<RegisterUser> getUser() {
    if (currentName == null) {
        currentName = new MutableLiveData<RegisterUser>();
    }
    return currentName;
}

public void onClick(View view) {

    RegisterUser registerUser = new RegisterUser(name.getValue(),EmailAddress.getValue(), Password.getValue());

    currentName.postValue(registerUser);

}

}

这是我在我的应用程序中使用的库:

implementation "android.arch.lifecycle:viewmodel:1.1.0"

也看到这个错误:

error: cannot find symbol class ActivityRegisterBindingImpl

在你的想法中,哪里有问题?

谢谢

java android
1个回答
0
投票

您是否在gradle文件中将数据绑定配置为true?

© www.soinside.com 2019 - 2024. All rights reserved.