android: data binding error: cannot find symbol class

后端 未结 26 2818
生来不讨喜
生来不讨喜 2020-12-14 05:49

I am getting started for using DataBinding feature. I am facing problem with it.

Error:(21, 9) error: cannot find symbol class ContactL

相关标签:
26条回答
  • 2020-12-14 06:18

    Make sure the name for your model and the reference have the same name:

    For example, name="item" must match android:checked="@={item.checked}"

    <data>
        <variable
            name="item"
            type="com.simone.mywordlist.model.MyModel" />
    </data>
    
                <Switch
                    android:id="@+id/my_switch"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:checked="@={item.checked}"
                />
    
    0 讨论(0)
  • 2020-12-14 06:18

    Keypoint

    Your layout name is in snake_case.

    activity_login.xml
    

    Then your binding class name will be in CamelCase.

    ActivityLoginBinding.java
    

    Also build project after creating layout. Sometimes it is not generated automatically.

    0 讨论(0)
提交回复
热议问题