我在我的应用程序中分配时遇到了问题。我可以在图形上使用glide并最小化这个问题吗?
buttonGraphic[0] = R.drawable.memory3;
buttonGraphic[1] = R.drawable.memory4;
buttonGraphic[2] = R.drawable.memory5;
buttonGraphic[3] = R.drawable.memory6;
buttonGraphic[4] = R.drawable.memory7;
buttonGraphic[5] = R.drawable.memory1;
buttonGraphic[6] = R.drawable.memory8;
buttonGraphic[7] = R.drawable.memory2;发布于 2017-05-12 01:24:48
根据我的理解,(如果我错了,请纠正我)你有一个OutOfMemoryException,这意味着你的应用程序不再有堆。
假设您的错误与创建位图对象有关
首先,我假设buttonGraphic是一个整数。如果你想给位图分配一个可绘制的,你必须这样做:(注意!创建位图实例的方法有很多种。这只是一种方法,而不是方法)
... = BitmapFactory.decodeResource(getResources()/*context.getResources()*/, R.drawable.memory8);如果将buttonGraphic数组指定为位图,则该数组的类型必须为位图
假设您的错误是OutOfMemoryException
这是一个困难的错误,因为您使用的内存(heap/ram)超过了您的应用程序的访问权限。
解决此错误的最简单方法是获取更多内存。使用清单中的这一行很容易做到这一点:
android:largeHeap="true"https://stackoverflow.com/questions/43921905
复制相似问题