使用软引用设置背景
2013-09-06 10:10
302 查看
imageView = (ImageView) findViewById(R.id.sItemIcon); imageView.setBackgroundDrawable(loadDrawable(R.drawable.id)); //软引用设置 private Map<Integer, SoftReference<Drawable>> imageCache = new HashMap<Integer, SoftReference<Drawable>>(); private Drawable loadDrawable(Integer id){ if(imageCache.containsKey(id)){ Drawable d=imageCache.get(id).get(); if(d!=null)return d; } Drawable d=getResources().getDrawable(id); imageCache.put(id, new SoftReference<Drawable>(d)); return d; }
相关文章推荐
- flex 使用AdvancedDataGrid进行表头列合并,设置每列背景颜色(1)
- listview使用xml文件和在代码中设置子类背景
- 使用ENVI将影像四周的黑背景设置为无色
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- ExtJS 使用点滴 七 如何设置EditorGridPannel 中特定行的背景
- QT下的几种透明效果(QPalette背景白色,窗口设置setWindowOpacity,QPainter使用Clear模式绘图)
- 在ARC下引用第三方库等使用MRC 设置 -fno-objc-arc无效
- 使用css设置图片背景透明,文字不透明
- 使用SlidingMenu问题:无法设置背景,滑动白边和返回键收起展开菜单
- C# *未能找到类型“ * ”,请确保已引用包含此类型的程序集。如果此类型为开发项目的一部分,请确保已使用针对当前平台或任意 CPU 的设置成功生成该项目
- ASP.NET控件使用——Gridview设置表头的背景图片
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例上
- TabLayout和ViewPager搭配使用中如何设置Tab背景颜色(无须自定义TabLayout)
- [转]引用 VC 对话框设置位图背景并透明控件
- 使用一个shape.xml文件,使用代码设置不同圆角背景颜色
- Android开发,使用背景图(xml drawable)为view 设置边框
- java使用layerpane设置背景图片
- 关于 QWidget无法使用stylesheet设置自身backgound-color(背景色)和border-image(背景图片) 的解决方法
- 一般处理程序使用Session报错(未将对象引用设置到对象实例)
- Android开发,使用背景图(xml drawable)为view 设置边框