Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a custom view get something like "onClose" or "onDestroy" event?

I have created a custom compound view by extending FrameLayout. That view can be on a dialogue box (among others). But what if I want to do some clean-up work when the view disappears from the screen, such as the user's closing the dialogue box? Can I get some kind of onDestroy event? Or should I make the owner (such as the dialogue box or the fragment) call the view's clean-up method on its (owner's) onDestroy or dismissed event?

like image 625
Damn Vegetables Avatar asked Jul 31 '18 11:07

Damn Vegetables


1 Answers

try to use

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
}
like image 81
UgAr0FF Avatar answered Oct 30 '22 00:10

UgAr0FF