release ImageView - Android User Interface

Android examples for User Interface:ImageView

Description

release ImageView

Demo Code


//package com.java2s;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

public class Main {
    public static void releaseImageView(ImageView view) {
        if (view == null)
            return;

        Drawable drawable = view.getDrawable();

        if (drawable != null && drawable instanceof BitmapDrawable) {
            BitmapDrawable res = (BitmapDrawable) drawable;
            Bitmap b = res.getBitmap();/*w ww.j a  v  a2s.  c o m*/

            if (b != null && !b.isRecycled())
                b.recycle();
        }

    }
}

Related Tutorials