Skip to content

Instantly share code, notes, and snippets.

@shaobin0604
Created August 2, 2013 02:33
Show Gist options
  • Select an option

  • Save shaobin0604/6137111 to your computer and use it in GitHub Desktop.

Select an option

Save shaobin0604/6137111 to your computer and use it in GitHub Desktop.
CleanUtil.java
public class CleanUtil {
private CleanUtil() {
}
public static void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
view.setBackground(null);
if (view instanceof ImageView) {
((ImageView) view).setImageDrawable(null);
}
}
if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment