Set null to ImageView. - Android User Interface

Android examples for User Interface:ImageView

Description

Set null to ImageView.

Demo Code


//package com.java2s;

import android.widget.ImageView;

public class Main {
    /**/*from   ww w.  j a va2 s  .  co m*/
     * Set null Image view.
     * 
     * @param view
     *            The {@link ImageView}
     */
    public static void setNullViewDrawable(ImageView view) {

        // remove resource of View.
        if (view != null) {

            if (view.getDrawable() != null) {
                view.getDrawable().setCallback(null);
            }
            if (view.getBackground() != null) {
                view.getBackground().setCallback(null);
            }
            view.setImageDrawable(null);
            view.getResources().flushLayoutCache();
            view.destroyDrawingCache();
            view.setBackgroundDrawable(null);
            view.setBackgroundResource(0);
            view = null;
        }
    }
}

Related Tutorials