Android数据绑定与findViewById的性能 [英] Android data binding vs findViewById for performance
问题描述
看起来, 文档:
视图带ID
将为每个视图生成一个公共final字段
布局中的ID。绑定在View层次结构上执行单次传递,
使用ID提取视图。这个机制可以比
调用几个视图的findViewById更快。
所以似乎数据绑定只需要做一个传递视图层次结构而不是我们总是调用findViewById。
I realize the potential for android data binding for MVVM is great and it opens doors. But regarding performance, is data binding faster then using findViewById in native android ?
It looks to me that it is faster per the docs:
Views With IDs
A public final field will be generated for each View with an ID in the layout. The binding does a single pass on the View hierarchy, extracting the Views with IDs. This mechanism can be faster than calling findViewById for several Views.
So it seems data binding only has to do a single pass over the view hierarchy instead of us always calling findViewById.
这篇关于Android数据绑定与findViewById的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!