Method to override when layout is destroyed in Android

I had success overriding the onAttachedToWindow() and onDetachedFromWindow() methods:

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    // View is now attached
}

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    // View is now detached, and about to be destroyed
}

Leave a Comment