unbind Drawables - Android android.graphics.drawable

Android examples for android.graphics.drawable:Drawable

Description

unbind Drawables

Demo Code

import android.view.View;
import android.view.ViewGroup;

public class Main {

  public static void unbindDrawables(View view) {
    if (view != null) {
      if (view.getBackground() != null) {
        view.getBackground().setCallback(null);
      }//from w  ww.  j a va2 s .  co  m
      if (view instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
          unbindDrawables(((ViewGroup) view).getChildAt(i));
        }

        try {
          ((ViewGroup) view).removeAllViews();
          view.destroyDrawingCache();
          return;
        } catch (Exception exception) {
          return;
        }
      }
    }
  }

}

Related Tutorials