Reputation: 530
I am thinking of making a reusable function to make views clickable to dismiss - in this example RelativeLayoutAO
is the background.
final RelativeLayout rlAO = (RelativeLayout) findViewById(R.id.RelativeLayoutAO);
Utility.setOnClickFinish(rlAO);
And then in the Utility class:
public class Utility {
public static void setOnClickFinish(View view) {
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View clickedView) {
((Activity) clickedView.getContext()).finish();
}
});
}
}
Would this cause a memory leak?
Upvotes: 1
Views: 595
Reputation: 6420
No, this should not cause a memory leak.
Based on the title of your question, I think it's possible that you are misunderstanding the implications of the static keyword here. You aren't setting anything "statically". The fact that setOnClickFinish() is marked as static simply means that it is a class method.
Upvotes: 2