在我的工作中,我需要你的帮助。我有一个带有两个图形的选项卡(mpandroidchart),这不支持同一布局中的其他图形(丢失垂直滚动条),我修复了这个,在选项卡中滑动时放入一个片段及其工作,但是当我按下其他选项卡时回来,程序崩溃,我真的需要你的帮助,我读到不能在片段内膨胀一个片段,我把片段放在xml中不是恐怖的。在其他标签中有一个谷歌地图片段和其他图表
这是我的代码
包含两个片段的布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="1800dp"
android:layout_marginTop="80dp"
android:theme="@style/AppTheme"
tools:context=".General_evolIP">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="1173dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="1800dp"
android:layout_marginTop="120dp">
<TextView
android:id="@+id/textView"
android:layout_width="352dp"
android:layout_height="78dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_horizontal"
android:text="Evolucion Indicadores Productivos"
android:textSize="30sp" />
<TextView
android:id="@+id/textView8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView"
android:text="Nº Peces vivos por region"
android:textSize="15sp" />
<fragment
android:id="@+id/fragmentFishAlive1"
class="com.ctwings.aquareport.fishAlive"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_marginTop="54dp"
tools:layout="@layout/fragment_general_evol_i" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp"
android:text="Peso Cosecha Mensual por Especie"
android:textSize="15sp" />
<fragment
android:id="@+id/fragmentFishHarvestWeight1"
class="com.ctwings.aquareport.harvestWeight"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
tools:layout="@layout/fragment_general_evol_i" />
<TextView
android:id="@+id/textViewgraphHeight"
android:layout_width="255dp"
android:layout_height="35dp"
android:layout_below="@+id/fragmentFishHarvestWeight1"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="242dp"
android:text="Mortalidad Mensual"
android:textSize="15sp" />
<com.jjoe64.graphview.GraphView
android:id="@+id/graphMortalityMonth"
android:layout_width="774dp"
android:layout_height="240dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="left|bottom"
android:layout_marginLeft="2dp" />
-->
</RelativeLayout>
</ScrollView>
这是我的错误
06-02 11:10:42.814 5537-5537/com.ctwings.aquareport E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ctwings.aquareport, PID: 5537
android.view.InflateException: Binary XML file line #41: Binary XML file line #41: Error inflating class fragment
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.ctwings.aquareport.General_evolIP.onCreateView(General_evolIP.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1430)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:732)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1025)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:503)
at com.ctwings.aquareport.DashboardActivity.setupDefaultPager(DashboardActivity.java:85)
at com.ctwings.aquareport.DashboardActivity.onNavigationItemSelected(DashboardActivity.java:182)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:151)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318)
at android.view.View.performClick(View.java:5201)
at android.view.View$PerformClick.run(View.java:21163)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: android.view.InflateException: Binary XML file line #41: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.ctwings.aquareport.General_evolIP.onCreateView(General_evolIP.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1430)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:732)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1025)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:503)
at com.ctwings.aquareport.DashboardActivity.setupDefaultPager(DashboardActivity.java:85)
at com.ctwings.aquareport.DashboardActivity.onNavigationItemSelected(DashboardActivity.java:182)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:151)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318)
at android.view.View.performClick(View.java:5201)
at android.view.View$PerformClick.run(View.java:21163)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.IllegalArgumentException: Binary XML file line #41: Duplicate id 0x7f0d00bf, tag null, or parent id 0xffffffff with another fragment for com.ctwings.aquareport.fishAlive
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2293)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:186)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.ctwings.aquareport.General_evolIP.onCreateView(General_evolIP.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1430)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:732)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1025)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:503)
at com.ctwings.aquareport.DashboardActivity.setupDefaultPager(DashboardActivity.java:85)
at com.ctwings.aquareport.DashboardActivity.onNavigationItemSelected(DashboardActivity.java:182)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:151)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318)
at android.view.View.performClick(View.java:5201)
at android.view.View$PerformClick.run(View.java:21163)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
我真的很了解你的帮助 感谢
答案 0 :(得分:0)
您的嵌套Fragment
布局是否包含View
同一个ID,并且主机View
布局中有另一个Fragment
?
这会导致错误,因为ViewGroup
树中有两个具有相同ID的视图。
您收到此错误说明:
二进制XML文件行#41:重复ID 0x7f0d00bf,标记null或父级 id 0xffffffff与另一个片段 com.ctwings.aquareport.fishAlive
这就是那个。