DataBinderMapperImpl 找不到 ActivityLoginBinding 的符号



我创建了登录活动。 但无法生成登录绑定文件。"error 在 DataBinderMapperImpl 中找不到符号 ActivityLoginBindingImpl。我可以添加什么?它应该以耳形方式生成自己。 登录活动:基本活动中的某些操作

public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginViewModel> implements View.OnClickListener, TextView.OnEditorActionListener {
@Inject
LoginViewModel loginViewModel;
ActivityLoginBinding activityLoginBinding = DataBindingUtil.setContentView(this, R.layout.activity_login);

@Override
public int getBindingVariable() {
return BR.viewModelLogin;
}
@Override
public int getLayoutId() {
return R.layout.activity_login;
}
@Override
public LoginViewModel getViewModel() {
return  loginViewModel;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityLoginBinding = getViewDataBinding();
loginViewModel.setNavigator(this);
activityLoginBinding.btnLogin.setOnClickListener(this);

}
@Override
public void handleError(Throwable throwable) {
// handle error
}
@Override
public void onClick(View v) {
activityLoginBinding.tvTranData.setText("");
}
private void getKeyboardGo(){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_GO) {
getKeyboardGo();
return true;
}
return false;
}
}

activity_login:

<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".LoginActivity">
<data>
<variable
name="viewModelLogin"
type="com.pax.e_kent.viewmodel.LoginViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<EditText
android:id="@+id/edtTCKN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberPassword"
android:hint="TC Kimlik Numaranız"
android:text="@={LoginViewModel.mTCKN}"
android:focusable="true"
android:imeOptions="actionNext"
android:maxLength="11"
android:textColor="@android:color/black"
android:textColorHint="@android:color/darker_gray"
android:textSize="20sp"
tools:layout_editor_absoluteX="101dp"
tools:layout_editor_absoluteY="203dp" />
<EditText
android:id="@+id/edtPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="10"
android:inputType="numberPassword"
android:hint="Şifreniz"
android:text="@={LoginViewModel.mPassword}"
android:focusable="true"
android:imeOptions="actionGo"
android:textColor="@android:color/black"
android:textColorHint="@android:color/darker_gray"
android:textSize="20sp"
tools:layout_editor_absoluteX="100dp"
tools:layout_editor_absoluteY="273dp" />
<Button
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_verify"
android:textColor="@drawable/custom_btn_text_color"
android:textSize="18sp"
android:layout_marginTop="10dp"
android:text="Giriş"
android:onClick="@{(v) -> LoginViewModel.onClick(v)}"
tools:layout_editor_absoluteX="161dp"
tools:layout_editor_absoluteY="362dp" />
<TextView
android:id="@+id/tv_tranData"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView></LinearLayout>
</layout>

LoginViewModel:我创建了LoginUser模型..................

public class LoginViewModel extends BaseViewModel<BaseNavigator> {
public MutableLiveData<String> mTCKN =new MutableLiveData<>();
public MutableLiveData<String > mPassword =new MutableLiveData<>();
private MutableLiveData<LoginUser> userMutableLiveData;
public MutableLiveData<LoginUser> getUser(){
if (userMutableLiveData == null) {
userMutableLiveData = new MutableLiveData<>();
}
return userMutableLiveData;
}
public void onClick(View view) {
LoginUser loginUser = new LoginUser(mTCKN.getValue(), mPassword.getValue());
userMutableLiveData.setValue(loginUser);
}
}

问题出在布局的按钮上。您尝试访问LoginViewModel方法作为static。检查以下内容:

android:onClick="@{(v) -> viewModelLogin.onClick(v)}"

而不是

android:onClick="@{(v) -> LoginViewModel.onClick(v)}"

相关内容

  • 没有找到相关文章

最新更新