Android - DataBinding - How and when the Binding classes will be generated?

后端 未结 18 1732
小蘑菇
小蘑菇 2021-02-03 16:51

DataBinding Guide States

  By default, a Binding class will be generated based on the name of the layout 
file, converting it to Pascal case and suffixing “Bindi         


        
18条回答
  •  鱼传尺愫
    2021-02-03 17:22

    My experience is that Android Studio 3.1.3 generated the databinding class after I clicked "Build > Rebuild Project". The file was stored in:

    \Project\app\build\generated\source\apt\development\debug\project\android\app\databinding

    However, Android Studio still reported the binding class as "Unknown" in source code.

    To finally fix it, I manually added the import statement:

    import project.android.app.databinding.*;

提交回复
热议问题