我很绝望,我不知道该怎么办。我已经尝试了很多东西来解决它,我总是离开OutOfMemory Error。我尝试使用Universal Image Loader库和许多其他网络修复程序,但我总是收到此错误:
03-13 12:45:05.151: E/AndroidRuntime(6460): FATAL EXCEPTION: main
03-13 12:45:05.151: E/AndroidRuntime(6460): java.lang.OutOfMemoryError
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:577)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:775)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.content.res.Resources.loadDrawable(Resources.java:1998)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.content.res.Resources.getDrawable(Resources.java:707)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.ImageView.resolveUri(ImageView.java:542)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.ImageView.setImageResource(ImageView.java:315)
03-13 12:45:05.151: E/AndroidRuntime(6460): at com.example.nititzart.jigsawpuzzle.ImageAdapter.getView(ImageAdapter.java:65)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.AbsListView.obtainView(AbsListView.java:2431)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.GridView.makeAndAddView(GridView.java:1323)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.GridView.makeRow(GridView.java:328)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.GridView.fillDown(GridView.java:281)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.GridView.fillGap(GridView.java:241)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5737)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4878)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.os.Handler.handleCallback(Handler.java:605)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.os.Handler.dispatchMessage(Handler.java:92)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.os.Looper.loop(Looper.java:137)
03-13 12:45:05.151: E/AndroidRuntime(6460): at android.app.ActivityThread.main(ActivityThread.java:4517)
03-13 12:45:05.151: E/AndroidRuntime(6460): at java.lang.reflect.Method.invokeNative(Native Method)
03-13 12:45:05.151: E/AndroidRuntime(6460): at java.lang.reflect.Method.invoke(Method.java:511)
03-13 12:45:05.151: E/AndroidRuntime(6460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
03-13 12:45:05.151: E/AndroidRuntime(6460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
03-13 12:45:05.151: E/AndroidRuntime(6460): at dalvik.system.NativeStart.main(Native Method)
我的应用程序在GridView中总共有50个图像。每个图像都是一个JPG文件,每个文件有25KB。我真的需要帮助,因为现在我完全被阻止而不知道还能做什么。
答案 0 :(得分:0)
你可以更好地使用Volley&优化的方式来实现图像加载
http://www.javacodegeeks.com/2013/06/android-volley-library-example.html