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

后端 未结 18 1724
小蘑菇
小蘑菇 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:23

    Make sure that the layout of the:

     
       
     
    

    Is in the activity_main.xml if you are looking for ActivityMainBinding. In most boilerplate projects you set your content view to activity_main.xml, but then inflate you fragment_main.xml.

    If you put your in fragment_main.xml layout then the class that is generated will be FragmentMainBinding.

    Note: This may seem obvious after reading, but it is something that can be easily overlooked when following the android documentation.

提交回复
热议问题