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

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

    Did you update your layout file for data binding? They are generated only for layouts which have data binding.

    It has to start with a layout tag which has 2 child tags (data & your root view).

    Something like this:

    
    
       
           
       
       
    
    

    When your layout has this form, AndroidStudio should auto complete the class. Also, by default, it is generated in .databinding package.

提交回复
热议问题