Skip to content Skip to sidebar Skip to footer

How To Implement Android Fragment Transaction .add Syntax Error

I'm would like to make my Android application use Fragment Transactions, so that I can switch between various Fragments display their associated lists. My application worked fine

Solution 1:

If you are already using the add method of FragmentTransaction you must not include the <fragment tag in your layout. What if you just left your main activity XML like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Solution 2:

In chapterFragment.java change your import

import android.app.Fragment

To

import android.support.v4.app.Fragment

Post a Comment for "How To Implement Android Fragment Transaction .add Syntax Error"