简体   繁体   English

调试android数据绑定?

[英]Debug android data binding?

Can anyone please tell me how can I debug or find the generated code from data binding. 任何人都可以请告诉我如何从数据绑定调试或查找生成的代码。 From this link I found out it generates the required code. 这个链接我发现它生成了所需的代码。

I guess you are looking for the auto-generated binding java files. 我猜你正在寻找自动生成的绑定java文件。

I was searching them too. 我也在搜索它们。 And finally I found them in this path: 最后我发现它们在这条道路上:

/app/build/intermediates/classes/debug/ {your package} /databinding/ActivityMainBinding.java / app / build / intermediates / classes / debug / {your package} /databinding/ActivityMainBinding.java

ie /app/build/intermediates/classes/debug/ com/example/databindingdtest /databinding/ActivityMainBinding.java ie / app / build / intermediates / classes / debug / com / example / databindingdtest /databinding/ActivityMainBinding.java

Please note that this auto-generated java file is named after your layout's name according to Google's guide : 请注意,根据Google指南 ,此自动生成的java文件以您的布局名称命名:

Custom Binding Class Names 自定义绑定类名称

By default, a Binding class is generated based on the name of the layout file, starting it with upper-case, removing underscores ( _ ) and capitalizing the following letter and then suffixing “Binding”. 默认情况下,基于布局文件的名称生成Binding类,以大写字母开头,删除下划线(_)并大写后面的字母,然后加上“Binding”后缀。 This class will be placed in a databinding package under the module package. 该类将放置在模块包下的数据绑定包中。 For example, the layout file contact_item.xml will generate ContactItemBinding. 例如,布局文件contact_item.xml将生成ContactItemBinding。 If the module package is com.example.my.app, then it will be placed in com.example.my.app.databinding. 如果模块包是com.example.my.app,那么它将放在com.example.my.app.databinding中。

Hope this can help you :-) 希望这可以帮到你 :-)

您无法调试它,因为它仅在编译时生成必要的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM