在我的应用程序中,我用其他片段用动画替换片段。其他片段打开完全但应用程序崩溃
java.lang.NullPointerException at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2796) at android.view.View.getDisplayList(View.java:12648) at android.view.View.getDisplayList(View.java:12694) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910) at android.view.View.getDisplayList(View.java:12588) at android.view.View.getDisplayList(View.java:12694) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910) at android.view.View.getDisplayList(View.java:12588) at android.view.View.getDisplayList(View.java:12694) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910) at android.view.View.getDisplayList(View.java:12588) at android.view.View.getDisplayList(View.java:12694) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2910) at android.view.View.getDisplayList(View.java:12588) at android.view.View.getDisplayList(View.java:12694) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1198) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2173) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
这是我的通话数据:
frameContainer = (FrameLayout) parentView.findViewById(R.id.frameContainerDialog);
FragmentManager fm = getChildFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment fragment = new FragmentConsultUserStep2(consultInfo);
int anim1 = R.anim.slide_in_right;
int anim2 = R.anim.slide_out_left;
ft.setCustomAnimations(anim1, anim2);
ft.replace(R.id.frameContainerDialog, fragment, "FRAGMENT_STEP2");
ft.commit();
我的动画类
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="100%"
android:toXDelta="0%" />
<!-- <alpha
android:duration="5000"
android:fromAlpha="loader0.loader0"
android:toAlpha="loader1.loader0" />-->
</set>
如果有人发现同样的问题并已解决,请告知我。
答案 0 :(得分:1)
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
DetailsFragment newFragment = DetailsFragment.newInstance();
ft.replace(R.id.details_fragment_container, newFragment, "detailFragment");
// Start the animated transition.
ft.commit();