Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android on view removed from parent

on a child layout (View) is there a callback for when the view is removed from it's parent? I need to recycle some images when the view is done. I've been looking around on the web for what to do, but haven't found anything helpful yet.

like image 351
Jacksonkr Avatar asked Sep 03 '12 20:09

Jacksonkr


2 Answers

I've been looking for something like this too. The best I can find is View.OnAttachStateChangeListener. I doubt it's ideal, as it's the callback for when the View is added & removed from the Window - not the parent, but it's sufficient for my needs.

like image 57
nmw Avatar answered Oct 14 '22 09:10

nmw


Instead of registering a new listener, you can override onDetachedFromWindow in your custom View code.

like image 5
marmor Avatar answered Oct 14 '22 10:10

marmor