I am using RecyclerViews in my app project and setting OnClickListeners with their ViewHolders (in their constructors like mentioned in a StackOverflow Q&A).
Then I have this question: how can I remove OnClickListeners from RecyclerView's ViewHolders when they are disposed.
Usually, we can remove an OnClickListener by doing this:
view.setOnClickListener(null);
And if it is a ViewPager's PagerAdapter, we can do so in destroyItem
method.
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
View view = container.findViewById(R.id.viewId);
view.setOnClickListener(null);
}
Where can I do so with RecyclerView? --Or, I need not do so?