Reputation: 11
I'm using a particular TextView: TextView txtStatusView = (TextView)findViewById(R.id.txtStatus);
in several methods in my view's .java file. In each method I'm using the above line of code to find and initialize the same txtStatus view. Should I instead be putting this once at the top of the class (my thought: to prevent wasting time or power finding the view every time), or is it better that I have this line for each method that uses the view?
Upvotes: 0
Views: 122
Reputation: 3212
Declare the variable globally and define it inside your onCreate()
Declare like:
TextView txtStatusView;
Inside onCreate():
txtStatusView = (TextView)findViewById(R.id.txtStatus);
Upvotes: 3