Android Efficiency - Views
Is it better to findViewById() once and store in the scope of your activity (class-wide) or call the above per use, so that the resources are reclaimed when the
Solution 1:
You're only storing references to views; the storage cost is minimal. Most quality code I've seen finds the view once for each activity, so I take that as best practice. Readability and maintainability are just bonuses.
Solution 2:
I think the performance difference is imperceptible. More important than that is how your code looks like... is it readable when you populate your activity class with findViewById
invocations?
Post a Comment for "Android Efficiency - Views"