I’ve got an Activity class. It should be really nice to find all the views I need in onCreate, and then just reference these fields, without calling findViewById. But is it OK to do so?
Can’t views be assigned different objects at runtime? E.g., is it always true that findViewById(res1) == findViewById(res1) at any time?
You can create instance variables for your views in an Activity. And
is true as long as the layout is not inflated again or other changes (replacing views) are made to the content view.
But do not keep references to views in objects that will live longer than the activity holding the views. Like in an Singleton! (see see Avoiding Memory Leaks)