4.01.2016

Android ImageView 設為空

原本的ImageView有塞圖,要將它清空:

        try{
            Bitmap _IMG = ((BitmapDrawable) view.getDrawable()).getBitmap();
            if(_IMG != null && !_IMG.isRecycled())
            {
                _IMG.recycle();
            }
            if(resource != -1) view.setImageResource(resource);
            else view.setImageDrawable(null);
        }catch (NullPointerException e){}