错误 –
java.lang.OutOfMemoryErrorat androID.graphics.BitmapFactory.nativeDecodeAsset(Native Method)at androID.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)at androID.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)at androID.graphics.drawable.Drawable.createFromresourceStream(Drawable.java:872)at androID.content.res.Resources.loadDrawable(Resources.java:3022)at androID.content.res.Resources.getDrawable(Resources.java:1586)at androID.vIEw.VIEw.setBackgroundResource(VIEw.java:16120)at com.info.laughingbuddha.Buddha4.onCreateVIEw(Buddha4.java:21)at androID.support.v4.app.Fragment.performCreateVIEw(Fragment.java:1500)at androID.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:927)at androID.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1104)at androID.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)at androID.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)at androID.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)at androID.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)at androID.support.v4.vIEw.VIEwPager.populate(VIEwPager.java:1068)at androID.support.v4.vIEw.VIEwPager.populate(VIEwPager.java:914)at androID.support.v4.vIEw.VIEwPager.run(VIEwPager.java:244)at androID.vIEw.Choreographer$CallbackRecord.run(Choreographer.java:803)at androID.vIEw.Choreographer.doCallbacks(Choreographer.java:603)at androID.vIEw.Choreographer.doFrame(Choreographer.java:572)at androID.vIEw.Choreographer$FramedisplayEventReceiver.run(Choreographer.java:789)at androID.os.Handler.handleCallback(Handler.java:733)at androID.os.Handler.dispatchMessage(Handler.java:95)at androID.os.Looper.loop(Looper.java:157)at androID.app.ActivityThread.main(ActivityThread.java:5293)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:515)at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1259)at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:1075)at dalvik.system.NativeStart.main(Native Method)
Buddha4.java-
package com.info.laughingbuddha;import androID.os.Bundle;import androID.support.v4.app.Fragment;import androID.text.method.ScrollingMovementMethod;import androID.vIEw.LayoutInflater;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.Widget.ImageVIEw;public class Buddha4 extends Fragment{ @OverrIDe public VIEw onCreateVIEw(LayoutInflater inflater,VIEwGroup container,Bundle savedInstanceState) { VIEw rootVIEw = inflater.inflate(R.layout.buddha,container,false); TextVIEwEx t = (TextVIEwEx) rootVIEw.findVIEwByID(R.ID.textVIEw2); t.setText("The Standing Happy Buddha brings riches and happiness.",true); t.setMovementMethod(new ScrollingMovementMethod()); ImageVIEw iv = (ImageVIEw) rootVIEw.findVIEwByID(R.ID.image1); iv.setBackgroundResource(R.drawable.buddha4); return rootVIEw; }}
我不知道我需要发布什么代码所以如果有人需要任何与此相关的代码请评论.谢谢.
解决方法 尝试使用以下代码行创建缩放位图:Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap,wIDth,height,true);
检查以下链接:
android – out of memory exception when creating bitmap
Android out of memory exception with bitmaps
Can I catch out of memory exception in Android in Bitmap allocation for decoding a picture file?
总结以上是内存溢出为你收集整理的android – 异常:OutOfMemoryError全部内容,希望文章能够帮你解决android – 异常:OutOfMemoryError所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)