我有一个AppBarLayout
带有 aToolbar
和 a的布局,ViewPager
带有 3 个选项卡。每个选项卡都通过Toolbar
'sActionMode
使用SearchView
. 当我们更新我们的应用程序以使用新的Support library 23.0.1
(针对 API 23,并使用构建工具 23.0.1)退出搜索模式时,应用程序会在以下堆栈中崩溃:
FATAL EXCEPTION: main
Process: com.package.name, PID: 3021
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:3937)
at android.view.ViewGroup.addView(ViewGroup.java:3787)
at android.view.ViewGroup.addView(ViewGroup.java:3728)
at android.view.ViewGroup.addView(ViewGroup.java:3701)
at android.support.v7.widget.Toolbar.addChildrenForExpandedActionView(Toolbar.java:1809)
at android.support.v7.widget.Toolbar$ExpandedActionViewMenuPresenter.collapseItemActionView(Toolbar.java:2048)
at android.support.v7.internal.view.menu.MenuBuilder.collapseItemActionView(MenuBuilder.java:1345)
at android.support.v7.internal.view.menu.MenuItemImpl.collapseActionView(MenuItemImpl.java:705)
at android.support.v7.widget.Toolbar.collapseActionView(Toolbar.java:570)
at android.support.v7.widget.Toolbar$3.onClick(Toolbar.java:1065)
at android.view.View.performClick(View.java:4781)
at android.view.View$PerformClick.run(View.java:19873)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
恢复Support library 22.0.1
一切正常。我看到我的onMenuItemActionCollapse
回调被调用,并返回 true,但它似乎在我的代码之外崩溃。