我有 GridLayout 作为子视图,设置(空)GridLayout.LayoutParams
setLayoutParams(new GridLayout.LayoutParams());
我没有在其他任何地方设置 LayoutParams。但我得到了例外
E/AndroidRuntime( 1620): FATAL EXCEPTION: main
E/AndroidRuntime( 1620): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.support.v7.widget.GridLayout$LayoutParams
E/AndroidRuntime( 1620): at android.support.v7.widget.GridLayout.computeLayoutParamsHashCode(GridLayout.java:872)
E/AndroidRuntime( 1620): at android.support.v7.widget.GridLayout.checkForLayoutParamsModification(GridLayout.java:879)
E/AndroidRuntime( 1620): at android.support.v7.widget.GridLayout.onMeasure(GridLayout.java:927)
E/AndroidRuntime( 1620): at android.view.View.measure(View.java:15172)
E/AndroidRuntime( 1620): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1249)
E/AndroidRuntime( 1620): at android.view.View.measure(View.java:15172)
E/AndroidRuntime( 1620): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
E/AndroidRuntime( 1620): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
E/AndroidRuntime( 1620): at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
E/AndroidRuntime( 1620): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
E/AndroidRuntime( 1620): at android.view.View.measure(View.java:15172)
E/AndroidRuntime( 1620): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
E/AndroidRuntime( 1620): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime( 1620): at android.view.View.measure(View.java:15172)
E/AndroidRuntime( 1620): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
E/AndroidRuntime( 1620): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
E/AndroidRuntime( 1620): at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
E/AndroidRuntime( 1620): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
E/AndroidRuntime( 1620): at android.view.View.measure(View.java:15172)
E/AndroidRuntime( 1620): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
E/AndroidRuntime( 1620): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime( 1620): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
E/AndroidRuntime( 1620): at android.view.View.measure(View.java:15172)
E/AndroidRuntime( 1620): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848)
E/AndroidRuntime( 1620): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100)
E/AndroidRuntime( 1620): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273)
E/AndroidRuntime( 1620): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
E/AndroidRuntime( 1620): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
E/AndroidRuntime( 1620): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
E/AndroidRuntime( 1620): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
E/AndroidRuntime( 1620): at android.view.Choreographer.doFrame(Choreographer.java:525)
E/AndroidRuntime( 1620): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
E/AndroidRuntime( 1620): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime( 1620): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1620): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1620): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 1620): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1620): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1620): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 1620): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 1620): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 304): Force finishing activity com.capsule.launcher/.LauncherActivity
为什么?