跳到主要内容
SUN / 笔记
← 全部文章

14.findViewById的过去及未来

We have lots of alternatives for this, and you may wonder why do we need another solution. Let’s compare the different solutions based on these criteria: null-safety, compile-time safety, and speed.

Column 1 ButterKnife Kotlin Synthetics Data Binding findViewById View Binding
Fast ❌ * ✅ ❌ * ✅ ✅
Null-safe ❌ ❌ ✅ ❌ ✅
Compile-time safe ❌ ❌ ✅ ✅ ** ✅

* ButterKnife and Data Binding solutions are slower because they use an annotation-based approach ** findViewById() is compile-time safe since API 26 because we don’t need to cast the type of view anymore.

https://juejin.cn/post/6905942568467759111

https://medium.com/mobile-app-development-publication/how-android-access-view-item-the-past-to-the-future-bb003ae84527

参考

相关文章

AndroidStudio使用教程(第六弹) →AndroidRuntime_ART与Dalvik →1.系统架构 →