Android: should I maintain a reference to the activity inside a recyclerview or is there another way?
问题 I need to use context methods within the onBindViewHolder (a standard example might be something as common as getString or getColor). Until now I've passed the context to the constructor for the recyclerview and maintained a reference in a variable, however this seems to me to be bad practice. Is there a way of getting context dynamically from inside a recyclerview without storing it as a variable? public SomeRecyclerViewClass(Activity activity) { this.parentActivity = activity; } 回答1: I