Android Performance - Views

Is it better to findViewById(<resource-id>) once and save it in its activity (throughout the class) or call the above for use so that the resources are fixed when leaving the current area / method?

I think it comes down to how expensive findViewById() compared to how expensive it is to store view objects in a class.

+4
source share
2 answers

You only save links to views; storage cost is minimal. The highest quality code I've seen looks at each presentation for each activity each time, so I accept this as best practice. Readability and maintainability are just bonuses.

+5
source

I think the performance difference is not noticeable. More importantly, what your code looks like ... is it readable when you populate your activity class with findViewById invocations?

0
source

All Articles