I have a ListView
and in it's adapter
's getView
method, I return a RelativeLayout
with MyButton
inside it.
MyButton
has a textView
and I have clickable words inside it (ClickableSpan
).
To make this work, I start with thew following line:
textView.setMovementMethod(LinkMovementMethod.getInstance());
Everything works perfectly but MAT shows that MyButton
leaks because of textView
. When I comment out the line above, nothing leaks.
Shall I set movementMethod
to null
? But even if so, I can't know the destruction moment of the button to set that to null
as it is inside of many other views.
What am I doing wrong? How to prevent this leak?
update
Solved the leak by setting text to empty string inside onDetachedFromWindow
, but I am still trying to find a documentation related to this behaviour. Why should I set the textview
to ""
?