I read many posts (one is this) and articles according to which you shouldn't pass context
from an Activity
to a non activity class, to avoid leak of memory.
I have to use the method findViewById()
in a non activity class.
So far,I did this:
public class Text{
Activity activity;
public Text(Activity activity){
this.activity = activity;
}
public TextView getMyTextView(){
return activity.findViewById(R.id.textView1)
}
}
Now I'm wondering if even "passing" an Activity
can lead to a memory leak.
What's the best way to be able to call, for example, the method findViewById
in a non activity class.