使用片段更改 Honeycomb 上的布局
在我的应用程序中,操作栏中有三个选项卡。
Tab A : contains 2 fragments
Tab B : contains a WebViewFragment
Tab C : contains a WebViewFragment
现在,我使用包含 LinearLayout 的全局布局。 我根据选项卡在 LinearLayout 中膨胀正确的布局。但是当我在 B -> 之间切换时答,我收到此错误:
Caused by: java.lang.IllegalArgumentException: Binary XML file line #8: Duplicate id 0x7f0a0002, tag null, or parent id 0xffffffff with another fragment for com.myapp.CategoriesFragment
处理此问题的最佳解决方案是什么?
我尝试删除AllViews/重新添加布局,但出现此异常:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
我认为我没有选择正确的解决方案。 感谢您的回答
In my application, I have three tabs in the Action Bar.
Tab A : contains 2 fragments
Tab B : contains a WebViewFragment
Tab C : contains a WebViewFragment
Now, I use a global layout containing a LinearLayout.
I inflate the right layout in the LinearLayout according to the tab. But when I switch between B -> A, I get this error :
Caused by: java.lang.IllegalArgumentException: Binary XML file line #8: Duplicate id 0x7f0a0002, tag null, or parent id 0xffffffff with another fragment for com.myapp.CategoriesFragment
What is the best solution to handle this ?
I have tried to removeAllViews / reAdd the layout, but I get this Exception :
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
I think I haven't choose the right solution.
Thanks for your answers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以选择一个内部容器来容纳碎片
请参阅下面的示例布局
You can choose an inner container to hold the fragments
Refer to the sample layout below