is it appropriate to define instance variables on the top of the class or we need to define them in onResume/onPause of the activity
1
-
1Can you elaborate on what you're trying to accomplish? Typically "instance variables" are members of the class and should be defined at that scope (the position in the file, i.e. top, doesn't matter).i_am_jorf– i_am_jorf2012-09-10 19:24:15 +00:00Commented Sep 10, 2012 at 19:24
Add a comment
|
2 Answers
Depends on the type of variable. There are some things (e.g. Views) that are not available until the layout is initialized. For others (e.g. resources) you need a Context so you'd have to wait until onCreate as well.
If you just want to define an integer or a String, namely, stuff that doesn't depend on the Android framework, go nuts.