user3195053
user3195053

Reputation: 39

DataBinding: cannot find symbol class

I've got a problem with databinding in android. Above are xml file and activity class:

activity_main.xml ( the binding is in android:enabled="@{loginInfo.existingUser}")

 <layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">

  <data>
  <variable
   name="loginInfo"
    type="com.example.android.loginapplication.LoginInfo"/>
  </data>

<LinearLayout
android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp">

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/new_customer"
            android:enabled="@{loginInfo.existingUser}"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/i_have_a_password"/>
    </RadioGroup>

    <EditText
    android:id="@+id/password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"/>
  </LinearLayout>

  </layout>

LoginInfoActivity.java

public class LoginInfoActivity extends AppCompatActivity {

private LoginInfo loginInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LoginInfoBinding binding = DataBindingUtil.setContentView(
            this, R.layout.activity_main);


    binding.setLoginInfo(loginInfo);
}
}

it can't find generated class LoginInfoBinding in LoginInfoActivity...

is the xml correct? Or it depends by other things?

Upvotes: 0

Views: 2802

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007584

The binding class is named after the layout resource by default. Your layout resource is activity_main.xml, so the binding is ActivityMainBinding.

Upvotes: 3

Related Questions