ViewGroup.dispatchCollectViewAttributes NPE

时间:2017-03-13 07:04:18

标签: android

java.lang.NullPointerException
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchCollectViewAttributes(ViewGroup.java:1112)
at android.view.ViewRootImpl.collectViewAttributes(ViewRootImpl.java:1038)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1304)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1005)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5609)
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:5001)
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:736)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
at dalvik.system.NativeStart.main(Native Method)

运行猴子我遇到了这个崩溃,似乎mChildren [i] null,这应该从未发生过。或者有任何可能的原因吗?

这是视图组中出现NPE的地方:

@Override
void dispatchCollectViewAttributes(AttachInfo attachInfo, int visibility) {
    if ((visibility & VISIBILITY_MASK) == VISIBLE) {
        super.dispatchCollectViewAttributes(attachInfo, visibility);
        final int count = mChildrenCount;
        final View[] children = mChildren;
        for (int i = 0; i < count; i++) {
            final View child = children[i];
            child.dispatchCollectViewAttributes(attachInfo,
                    visibility | (child.mViewFlags&VISIBILITY_MASK));
        }
    }
}

0 个答案:

没有答案