gpt4 book ai didi

android - ActionBar 选项卡和主从布局

转载 作者:行者123 更新时间:2023-11-30 03:38:26 26 4
gpt4 key购买 nike

我在操作栏选项卡和使主/细节布局正常工作时遇到问题。

我有主/细节工作,但我现在正在添加选项卡,因此我可以选择不同的布局。但是,它似乎因错误而崩溃:

04-27 13:00:45.805: E/AndroidRuntime(5161): android.view.InflateException: Binary XML file line #24: Error inflating class fragment
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-27 13:00:45.805: E/AndroidRuntime(5161): at com.example.example.masterdetail_tabs.Tab1Fragment.onCreateView(Tab1Fragment.java:17)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.Fragment.performCreateView(Fragment.java:1695)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1255)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.BackStackRecord.run(BackStackRecord.java:672)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.os.Handler.handleCallback(Handler.java:725)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.os.Handler.dispatchMessage(Handler.java:92)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.os.Looper.loop(Looper.java:137)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-27 13:00:45.805: E/AndroidRuntime(5161): at java.lang.reflect.Method.invokeNative(Native Method)
04-27 13:00:45.805: E/AndroidRuntime(5161): at java.lang.reflect.Method.invoke(Method.java:511)
04-27 13:00:45.805: E/AndroidRuntime(5161): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-27 13:00:45.805: E/AndroidRuntime(5161): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-27 13:00:45.805: E/AndroidRuntime(5161): at dalvik.system.NativeStart.main(Native Method)
04-27 13:00:45.805: E/AndroidRuntime(5161): Caused by: java.lang.IllegalArgumentException: Binary XML file line #24: Duplicate id 0x7f060001, tag null, or parent id 0x0 with another fragment for com.example.example.masterdetail_tabs.ItemListFragment
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
04-27 13:00:45.805: E/AndroidRuntime(5161): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)

我创建了一个简单的应用程序来重现问题(不知道这是否是一个问题,但我在真实应用程序中使用 actionbarsherlock)

https://github.com/abidk/android_masterdetail_tab_issue

有人知道我做错了什么吗?

最佳答案

如果有人想知道解决方案是用框架布局替换 *_twopane.xml 中的 fragment ,然后以编程方式添加列表组件。

getFragmentManager().beginTransaction()
.replace(R.id.item_list, new ItemListFragment())
.commit();

关于android - ActionBar 选项卡和主从布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16251952/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com