Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear ImageView correctly?

For example, in my Activity I have such code (I skip the initialization of variables):

ImageView iview; //some ImageView
Bitmap b; //some Bitmap
iview.setImageBitmap(b);

Question is - how to clear iview resources correctly (with or without destroying view) ? Would ImageView free it's resources (used in native code) after b.recycle()?

I suppose, that ImageView doesn't just free it resources after Activity onStop (or onDestroy).

like image 335
Dmitry Zaytsev Avatar asked Feb 29 '12 11:02

Dmitry Zaytsev


2 Answers

imgview.setImageResource(0);

or

imgview.setImageDrawable(null);
like image 98
Samir Mangroliya Avatar answered Sep 18 '22 06:09

Samir Mangroliya


no you need to unbindDrawables, you can do it by setting iview.setImageDrawable(null);

like image 37
jeet Avatar answered Sep 18 '22 06:09

jeet