您的位置:首页 > 其它

使用软引用设置背景

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;
	}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐