片段

时间:2017-11-20 11:15:16

标签: java android

 private void changeFragment(Fragment targetFragment) {
        resideMenu.clearIgnoredViewList();
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.main_fragment, targetFragment, "fragment")
                .setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                .commit();
    }

android.support.v4.app.FragmentManagerImpl.enqueueAction FragmentManager.java:1864 2 android.support.v4.app.BackStackRecord.commitInternal BackStackRecord.java:650 3 android.support.v4.app.BackStackRecord.commit BackStackRecord.java:609 4 com.example.ramzan.lazurd.MainActivity.changeFragment MainActivity.java:391 五 com.example.ramzan.lazurd.MainActivity.onCreate MainActivity.java:156 6 android.app.Activity.performCreate Activity.java:6904 7 android.app.Instrumentation.callActivityOnCreate Instrumentation.java:1136 8 android.app.ActivityThread.performLaunchActivity ActivityThread.java:3266 9 android.app.ActivityThread.handleLaunchActivity ActivityThread.java:3415 10 android.app.ActivityThread.access $ 1100 ActivityThread.java:229 11 android.app.ActivityThread $ H.handleMessage ActivityThread.java:1821 12 android.os.Handler.dispatchMessage Handler.java:102 13 android.os.Looper.loop Looper.java:148 14 android.app.ActivityThread.main ActivityThread.java:7406 15 java.lang.reflect.Method.invoke Method.java 16 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run ZygoteInit.java:1230 17 com.android.internal.os.ZygoteInit.main ZygoteInit.java:1120

1 个答案:

答案 0 :(得分:0)

我认为您需要找到片段事务提交

喜欢这个fragmentTransaction.commit();

并改变:

fragmentTransaction.commitAllowingStateLoss();