问题描述
- Android ViewGroup 图片内存回收问题
-
小弟在网上看到一篇将ViewGroup中图片内存回收的文章,但是有一些疑问
链接是http://hi.baidu.com/jwq359699768/item/c80c9cf3bcd1cbc0a835a2a6代码是:
private void recycleBitmap( )
{
if(viewGroup != null)
{
int count = viewGroup.getChildCount;
for(int i=0; i <count; i++ )
{
View view = viewGroup.getChildAt(i);
ImageView img = (ImageView)view.findViewById(R.id.Image);
if(img != null)
{
Drawable drawable = img.getDrawable( );
if(drawable != null)
{
if(drawable instanceof BitmapDrawable)
{
BitmapDrawable bitmapDrawable = (BitmapDrawable)drawable;
Bitmap bitmap = bitmapDrawable.getBitmap( );
if(bitmap != null)
bitmap.recycle( );
}
}
}
}
}
}其中ImageView img = (ImageView)view.findViewById(R.id.Image);这句话将取得的第i个View中的图片通过findViewById的方法取出来,但是这个View中的ImageView的Id是怎么得知的呢?