我已经用 5 个标签实现了 tabactivity。当我改变方向和 tabchange 时,我遇到了 outOfMemory 问题。
我试着去
setRetainInstance(true);
还设置
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }
在我的片段和框架活动中。
- 也在
android:configChanges="keyboardHidden|orientation|screenLayout|screenSize"
清单中添加。
但没有运气。我在下面添加了我的 logcat,
09-03 10:34:30.475: E/dalvikvm-heap(8691): Out of memory on a 6554896-byte allocation.
09-03 10:34:30.475: I/dalvikvm(25175): "main" prio=5 tid=1 RUNNABLE
09-03 10:34:30.475: I/dalvikvm(25175): | group="main" sCount=0 dsCount=0 obj=0x41127508 self=0x410c5b78
09-03 10:34:30.475: I/dalvikvm(25175): | sysTid=25175 nice=0 sched=0/0 cgrp=apps handle=1074904880
09-03 10:34:30.475: I/dalvikvm(25175): | schedstat=( 7353555166 1878419412 11747 ) utm=577 stm=157 core=3
09-03 10:34:30.475: I/dalvikvm(25175): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
09-03 10:34:30.475: I/dalvikvm(25175): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
09-03 10:34:30.475: I/dalvikvm(25175): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:476)
09-03 10:34:30.475: I/dalvikvm(25175): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
09-03 10:34:30.475: I/dalvikvm(25175): at android.content.res.Resources.loadDrawable(Resources.java:1963)
09-03 10:34:30.475: I/dalvikvm(25175): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-03 10:34:30.475: I/dalvikvm(25175): at android.view.View.<init>(View.java:3444)
09-03 10:34:30.475: I/dalvikvm(25175): at android.view.View.<init>(View.java:3377)
09-03 10:34:30.475: I/dalvikvm(25175): at android.view.ViewGroup.<init>(ViewGroup.java:426)
09-03 10:34:30.475: I/dalvikvm(25175): at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
09-03 10:34:30.475: I/dalvikvm(25175): at java.lang.reflect.Constructor.constructNative(Native Method)
09-03 10:34:30.475: I/dalvikvm(25175): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
09-03 10:34:30.475: I/dalvikvm(25175): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
09-03 10:34:30.475: I/dalvikvm(25175): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-03 10:34:30.480: I/dalvikvm(25175): at com.dameco.Settings.onCreateView(Settings.java:113)
09-03 10:34:30.480: I/dalvikvm(25175): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
09-03 10:34:30.480: I/dalvikvm(25175): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
09-03 10:34:30.480: I/dalvikvm(25175): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
09-03 10:34:30.480: I/dalvikvm(25175): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
09-03 10:34:30.480: I/dalvikvm(25175): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:523)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.Activity.performStart(Activity.java:5216)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1941)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
09-03 10:34:30.480: I/dalvikvm(25175): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:705)
09-03 10:34:30.480: I/dalvikvm(25175): at android.widget.TabHost.setCurrentTab(TabHost.java:369)
09-03 10:34:30.480: I/dalvikvm(25175): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:150)
09-03 10:34:30.480: I/dalvikvm(25175): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:560)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.View.performClick(View.java:4223)
09-03 10:34:30.480: I/dalvikvm(25175): at android.view.View$PerformClick.run(View.java:17275)
09-03 10:34:30.480: I/dalvikvm(25175): at android.os.Handler.handleCallback(Handler.java:615)
09-03 10:34:30.480: I/dalvikvm(25175): at android.os.Handler.dispatchMessage(Handler.java:92)
09-03 10:34:30.480: I/dalvikvm(25175): at android.os.Looper.loop(Looper.java:137)
09-03 10:34:30.480: I/dalvikvm(25175): at android.app.ActivityThread.main(ActivityThread.java:4898)
09-03 10:34:30.480: I/dalvikvm(25175): at java.lang.reflect.Method.invokeNative(Native Method)
09-03 10:34:30.480: I/dalvikvm(25175): at java.lang.reflect.Method.invoke(Method.java:511)
09-03 10:34:30.480: I/dalvikvm(25175): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
09-03 10:34:30.480: I/dalvikvm(25175): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
09-03 10:34:30.480: I/dalvikvm(25175): at dalvik.system.NativeStart.main(Native Method)
请就此给我建议。谢谢。