com.android.support:recyclerview-v7:+和setCustomAnimations

时间:2016-03-15 14:22:29

标签: android-animation android-support-library

我用下一个代码替换我的应用程序中的片段

FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
        fragmentManager.beginTransaction()
                //.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
                .replace(R.id.main, newFragment)
                .addToBackStack(Tag)
                .commit();

当我取消注释时

.setCustomAnimations(R.anim.enter_from_right, 
R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)

我有致命错误,但它之前运作良好。我认为AndroidStudio中的原因(当前版本1.5.1,SDK或libs)。代码突然停止工作,但在使用AndrodStudio 1.5在另一台PC上编译后继续工作 重新安装Android Studio的唯一方法是希望它对我有所帮助。但我想知道发生了什么。    第一个问题是: can't access to TextView

此代码也正常。

也许有人可以解释什么是错误的

- enter_from_left.xml ----

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="-100%" android:toXDelta="0%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200"/>
</set>

--- enter_from_right.xml ---

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="100%" android:toXDelta="0%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200" />
</set>

--- exit_to_left.xml ---

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="0%" android:toXDelta="-100%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200"/>
</set>

--- exit_to_right.xml ---

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="0%" android:toXDelta="100%"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="200" />
</set>
FATAL EXCEPTION: main
                                                            Process: , PID: 24774
                                                            java.lang.NullPointerException
                                                                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2939)
                                                                at android.view.View.getDisplayList(View.java:13368)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3077)
                                                                at android.view.View.getDisplayList(View.java:13311)
                                                                at android.view.View.getDisplayList(View.java:13415)
                                                                at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
                                                                at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
                                                                at android.view.ViewRootImpl.draw(ViewRootImpl.java:2420)
                                                                at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2292)
                                                                at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1922)
                                                                at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1039)
                                                                at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5648)
                                                                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
                                                                at android.view.Choreographer.doCallbacks(Choreographer.java:574)
                                                                at android.view.Choreographer.doFrame(Choreographer.java:544)
                                                                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
                                                                at android.os.Handler.handleCallback(Handler.java:733)
                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                at android.os.Looper.loop(Looper.java:136)
                                                                at android.app.ActivityThread.main(ActivityThread.java:5047)
                                                                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:806)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
                                                                at dalvik.system.NativeStart.main(Native Method)
我知道吗?在ADK版本的原因,一切工作在最后版本compileSdkVersion 23 buildToolsVersion&#34; 23.0.1&#34;

另一个AndroidStudio上的一切正常,所有问题都在更新到Android N后开始

1 个答案:

答案 0 :(得分:0)

我从build.gradle中删除了一行“com.android.support:recyclerview-v7:+”并且everething正常工作

dependencies {

   compile 'com.android.support:recyclerview-v7:+'
}

我不知道为什么,只是通过连续的排除

如果我使用

,那一切都没问题
compile 'com.android.support:recyclerview-v7:23.2.1'