如何修复错误“java.lang.IllegalStateException:布局状态应该是100之一,但它是10”?

时间:2016-06-07 01:54:38

标签: android android-recyclerview

我有错误java.lang.IllegalStateException: Layout state should be one of 100 but it is 10。在错误的跟随信息下面。

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IllegalStateException: Layout state should be one of 100 but it is 10 
at android.support.v7.widget.RecyclerView$State.assertLayoutStep(RecyclerView.java:10053)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3045) 
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2917)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:596) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2029)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1850)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1143)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4667)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)

请帮我纠正这个错误。感谢

2 个答案:

答案 0 :(得分:1)

我有一个非常类似的错误日志,就像你的一样,几乎一样。 在我的例子中,我在.xml中有一个TextView,但是将其转换为Adapter.java中的Button。

    TextView tv = (TextView) convertView.findViewById(R.id.button_id); // wrong

可以复制此错误。 但是将Button转换为TextView时不会发生。

答案 1 :(得分:-2)

我也遇到了这个错误,我的错误是由onBindViewHolder导致的方法classCastException产生的。但异常堆栈没有清楚地显示出来。

我认为这可能会有所帮助。