Damn Vegetables
Damn Vegetables

Reputation: 12504

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?

Upvotes: 8

Views: 2347

Answers (1)

UgAr0FF
UgAr0FF

Reputation: 825

try to use

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
}

Upvotes: 14

Related Questions