java.lang.IllegalArgumentException:视图不是子视图,无法隐藏

时间:2017-05-12 02:15:27

标签: java android android-recyclerview

Recyclerview升级到v23.4.0然后发现此崩溃:

    java.lang.IllegalArgumentException: view is not a child, cannot hide com.xxx.ViewGroupGridView{32112cd4 V.E..... .......D 0,1443-1080,2277 #7f0b161c app:id/gv_menu_list}

    android.support.v7.widget.ChildHelper.unhide(ChildHelper.java:352)

    android.support.v7.widget.RecyclerView$Recycler.getScrapViewForPosition(RecyclerView.java:5080)
        android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4634)
        android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
        android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
        android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)
        android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
        android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:584)
        android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
        android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2625)
        android.view.View.measure(View.java:17788)
        android.widget.RelativeLayout.measureChild(RelativeLayout.java:816)
        android.widget.RelativeLayout.onMeasure(RelativeLayout.java:561)
        android.view.View.measure(View.java:17788)
        android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5636)
        android.widget.FrameLayout.onMeasure(FrameLayout.java:459)
        android.view.View.measure(View.java:17788)
        android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:846)
        android.widget.RelativeLayout.onMeasure(RelativeLayout.java:512)
        android.view.View.measure(View.java:17788)
        android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5636)
        android.widget.FrameLayout.onMeasure(FrameLayout.java:459)
        android.view.View.measure(View.java:17788)
        android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5636)
        android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1692)
        android.widget.LinearLayout.measureVertical(LinearLayout.java:760)
        android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
        android.view.View.measure(View.java:17788)
        android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5636)
        android.widget.FrameLayout.onMeasure(FrameLayout.java:459)
        com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2712)
        android.view.View.measure(View.java:17788)
        android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2482)
        android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1436)
        android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1704)
        android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1314)
        android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6715)
        android.view.Choreographer$CallbackRecord.run(Choreographer.java:800)
        android.view.Choreographer.doCallbacks(Choreographer.java:603)
        android.view.Choreographer.doFrame(Choreographer.java:572)
        android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:786)
        android.os.Handler.handleCallback(Handler.java:815)
        android.os.Handler.dispatchMessage(Handler.java:104)
        android.os.Looper.loop(Looper.java:213)
        android.app.ActivityThread.main(ActivityThread.java:5819)
        java.lang.reflect.Method.invoke(Native Method)
        java.lang.reflect.Method.invoke(Method.java:372)
        com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:998)
        com.android.internal.os.ZygoteInit.main(ZygoteInit.java:793)

This is layout file. ViewGroupGridView是一个扩展linearLayout的常见视图,我只是在RecyclerView中使用这个绑定数据。

1 个答案:

答案 0 :(得分:0)

我有相同的问题,在这个主题上的搜索显示了一个库的github问题和这个问题,其中一项评论很有趣。

如果您的页眉或项目的高度为wrap_content,请尝试将其更改为固定高度,然后查看崩溃是否消失。

Here is that comment

我将尝试相同的操作,并将在几天后发布更新。