Do I need to view View.OnClickListener from views during onDestroy for free?

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?

+4
source share
1 answer

, onClickListener onDestroy. , , , . , , .

+5

Source: https://habr.com/ru/post/1666436/


All Articles