I have a large project with 100 fragments. They all largely follow the example that I will tell, and my question will follow.
public class MyFragment extends Fragment implements View.OnClickListener {
public void onDestroy(...) {
}
public void onCreateView(...) {
...
root.findViewById(R.id.some_button).setOnClickListener(this);
return root;
}
public void onClick(View v) { ... }
}
Is it necessary to free the listener from fragment in onDestroy? Is it a memory leak or can cause any problems? Is it considered good practice to clean them? And if an explanation is possible why?
source
share