I got a Activity class which implement a Actionbar with two Tabs. Each Tab is calling a other Fragment??.class over the TabListener. If I start the Application the FragmentXY.class is called. I can switch to the second Tab without any problem. But if I switch back to the first Tab which contains the two other fragments as a split-screen, the application crashed and throw the Error :InflateException binary xml file line : Error inflating class fragment
tab = actionBar
.newTab()
.setText("My Box")
.setIcon(android.R.drawable.ic_menu_help)
.setTabListener(new MyTabListener<FragmentXY>(this, "myXY",FragmentXY.class));
actionBar.addTab(tab);
tab = actionBar
.newTab()
.setText("QR-Code")
.setIcon(android.R.drawable.ic_menu_add)
.setTabListener(new MyTabListener<FragmentXYZ>(this, "barcode",FragmentXYZ.class));
actionBar.addTab(tab);
Each Fragment.class is calling a xml resource which contain once two other fragments or only one Fragment.
FragmentXY.class
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.first_tab, container, false);
return view;
}
first_tab.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:name="com.febro.myfragmenttest.ListFragment"
android:id="@+id/listFragment"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
class="com.febro.myfragmenttest.ListFragment" ></fragment>
<fragment
android:name="com.febro.myfragmenttest.DetailFragment"
android:id="@+id/detailFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.febro.myfragmenttest.DetailFragment" >
</fragment>
</LinearLayout>
Is it a problem with the callback-methode?
Here is the full error report from logcat:
09-12 19:57:06.300: D/AndroidRuntime(2799): Shutting down VM
09-12 19:57:06.300: W/dalvikvm(2799): threadid=1: thread exiting with uncaught exception (group=0x4015d760)
09-12 19:57:06.310: E/AndroidRuntime(2799): FATAL EXCEPTION: main
09-12 19:57:06.310: E/AndroidRuntime(2799): android.view.InflateException: Binary XML file line #6: Error inflating class fragment
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:688)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
09-12 19:57:06.310: E/AndroidRuntime(2799): at com.febro.myfragmenttest.FragmentXY.onCreateView(FragmentXY.java:26)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:776)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1133)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.BackStackRecord.run(BackStackRecord.java:628)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1309)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:398)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.os.Handler.handleCallback(Handler.java:587)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.os.Looper.loop(Looper.java:132)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.ActivityThread.main(ActivityThread.java:4126)
09-12 19:57:06.310: E/AndroidRuntime(2799): at java.lang.reflect.Method.invokeNative(Native Method)
09-12 19:57:06.310: E/AndroidRuntime(2799): at java.lang.reflect.Method.invoke(Method.java:491)
09-12 19:57:06.310: E/AndroidRuntime(2799): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
09-12 19:57:06.310: E/AndroidRuntime(2799): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
09-12 19:57:06.310: E/AndroidRuntime(2799): at dalvik.system.NativeStart.main(Native Method)
09-12 19:57:06.310: E/AndroidRuntime(2799): Caused by: java.lang.IllegalArgumentException: Binary XML file line #6: Duplicate id 0x7f090008, tag null, or parent id 0xffffffff with another fragment for com.febro.myfragmenttest.ListFragment
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.app.Activity.onCreateView(Activity.java:4182)
09-12 19:57:06.310: E/AndroidRuntime(2799): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:664)
09-12 19:57:06.310: E/AndroidRuntime(2799): ... 18 more
09-12 19:57:06.320: W/ActivityManager(302): Force finishing activity com.febro.myfragmenttest/.ActionbarMain
09-12 19:57:06.400: D/dalvikvm(302): GC_FOR_ALLOC freed 13157K, 52% free 12567K/26055K, paused 68ms
simply extends your class extends FragmentActivity
instead of extends Activity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With