我的activity中调用了一张大图,在启动新的activity之后再返回原activity的时候,有时候会出现内存不足的异常,请教各位有没有好的处理办法?
解决方案 »
- 通過藍牙連接藍牙打印機,在線等!
- 新手学android软件编写
- 请教如何将文件打包进android安装包的/data文件夹下
- Android LogCat 中显示的颜色和字体怎么改?
- android关于蓝牙打印机的问题,请各位大大帮帮忙撒
- 怎么获知SoftInput键盘是否处于打开状态
- 真心搞不定了,画了一个Path,然后在path里面平铺图像。怎么将path变成bitmap或是什么东西,在线等!!!!
- ImageView.setVisibility(View.VISIBLE),图片显示不出来,求大神帮忙!
- 用eclipse打开Genymotion虚拟机时候出错,求指导(尽可能详细)
- 练习,下了百度地图SDK,然后做完后发现菜单没了,求懂得教下,拜托了
- 谁能在线给我搭建 Andorid环境啊
- 菜单使用的一个问题,请教各位牛人
ImageView img = (ImageView) findViewById(R.id.img_front);
try{
img.setVisibility(View.GONE);
img.setImageDrawable(getResources().getDrawable(R.drawable.blank));
if (sClass.equals("A")){
img.setImageDrawable(getResources().getDrawable(R.drawable.all_jl));
}else if (sClass.equals("B")){
img.setImageDrawable(getResources().getDrawable(R.drawable.hand_xj));
}
img.setVisibility(View.VISIBLE);
}
catch (OutOfMemoryError e) {
Log.w("Memory", "Touch:createBitmapByScale OutOfMemoryError.", e);
Toast.makeText(Touch.this, "显示内存不足,建议退出程序并重新选择!",Toast.LENGTH_SHORT).show();
//TODO: out of memory deal..
}没有Try之前就会崩溃,Try之后从这里就会捕获异常。
if (sClass.equals("A")){
drawable = getResources().getDrawable(R.drawable.all_jl);
img.setImageDrawable(drawable);
}else if (sClass.equals("B")){
drawable = getResources().getDrawable(R.drawable.hand_xj);
img.setImageDrawable(drawable);
}
drawable = null;试试看
2.裁剪缩小图片大小。关于其他的方法,网上有帖子说明解决实例的。把你LOG里的错误贴上去,搜搜。