unbind View Image Drawables - Android User Interface

Android examples for User Interface:View Bitmap

Description

unbind View Image Drawables

Demo Code


//package com.java2s;

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

import android.widget.ImageView;

public class Main {
    public static void unbindImageDrawables(View view) {
        if (null == view) {
            return;
        }// w w  w  .j  a  va2  s.co m

        if (view instanceof ImageView) {
            ImageView imageView = (ImageView) view;

            if (imageView.getDrawable() != null) {
                imageView.getDrawable().setCallback(null);
                imageView.setImageDrawable(null);
            }
        }
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                unbindImageDrawables(((ViewGroup) view).getChildAt(i));
            }
        }
    }
}

Related Tutorials