Is it good to call findViewById every time in Activity lifecycle whenever required?

前端 未结 6 1158
余生分开走
余生分开走 2020-12-20 13:56

Whenever we need a reference to the widget, we uses findByViewById.

When we are referring the widget lots of time in the code of the same Activity class, we can fol

6条回答
  •  一个人的身影
    2020-12-20 14:27

    You should decide this according to your purpose. Holding an object for your views are faster than getting your view with an activity method. But this also means that you are using a memory for your reference and it can cause a memory leak.

提交回复
热议问题