读书人

Gallery件小结及OutOfMemoryErr

发布时间: 2012-07-03 13:37:43 作者: rapoo

Gallery件总结及OutOfMemoryError: bitmap size exceeds VM budget解决
超炫的3D特效程序管理功能android
http://www.cnblogs.com/tankaixiong/archive/2011/02/26/1965564.html



eoe的这个...有问题..
Android Gallery控件使用方法详解.
http://www.eoeandroid.com/thread-102959-1-1.html

Android Gallery控件使用方法详解
http://blog.csdn.net/super005/article/details/5845066

Android 控件使用之 Gallery
http://blog.csdn.net/dadahacker/article/details/5722916

Android-ListView实现Gallery效果三-自定义列表
http://disanji.net/2011/01/10/android-listview-gallery-sample-3/

java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法
1.http://www.devdiv.com/thread-49664-1-1.html
2.http://blog.sina.com.cn/s/blog_672f41790100t35n.html
完美解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget
http://blog.csdn.net/yangxyjd/article/details/6932989
3.http://lzyfn123.iteye.com/blog/1457628


BitmapFactory.Options opts = new BitmapFactory.Options();opts.inJustDecodeBounds = true;BitmapFactory.decodeFile(imageFile, opts);opts.inSampleSize = computeSampleSize(opts, -1, 128*128);opts.inJustDecodeBounds = false;try {Bitmap bmp = BitmapFactory.decodeFile(imageFile, opts);imageView.setImageBitmap(bmp);    } catch (OutOfMemoryError err) {} 



修改如下,没有出现OOM错误
opts.inSampleSize = computeSampleSize(opts, -1, 1024*1024);




这个讨论的很深入:
http://blog.csdn.net/woshicaixianfeng/article/details/6825295

public static Bitmap readBitMap(Context context, int resId){          BitmapFactory.Options opt = new BitmapFactory.Options();          opt.inPreferredConfig = Bitmap.Config.RGB_565;          opt.inPurgeable = true;         opt.inInputShareable = true;         InputStream is = context.getResources().openRawResource(resId);             return BitmapFactory.decodeStream(is,null,opt);      }

解决大问题

读书人网 >Ruby Rails

热点推荐