zhangyunan66 2014-03-10 12:38 采纳率: 0%
浏览 2573

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是怎么得知的呢?

  • 写回答

1条回答 默认 最新

  • 未知账号 2017-06-15 06:14
    关注

    这个应该可以传个值进去,在不同的地方调用,传递不一样的参数。。。。

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料