1

I’m trying to make footer for my fragment. I succeed to do it but still have a problem when I load this fragment for the first time it's work well, but when I change the fragments in my navigation drawer and trying to get this fragment for the second time the app crash and the log error show me an error :

 android.view.InflateException: Binary XML file line #17: Error inflating class fragment
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 Caused by: java.lang.IllegalArgumentException: Binary XML file line #17: 
 Duplicate id 0x7f070084, tag null, or parent id 0x7f070082 with another fragment for   com.example.user.unchained.FooterHome

So any one have an idea to resolve the problem

The OnCreateView Function :

 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        v =   inflater.inflate(R.layout.fragment_homes, container, false);

        listView = (ListView) v.findViewById(R.id.homeList);

        l = new HomeListAdapter(this, homeList);
        listView.setAdapter(l);

        return v;

    }

The main Layout XML :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dark_grey"
android:id="@+id/fHome"
tools:context="com.example.user.unchained.HomesActivity$PlaceholderFragment">

<ListView
    android:id="@+id/homeList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:dividerHeight="1dp"
    android:choiceMode="singleChoice"
    android:listSelector="@drawable/list_row_selector" />

<fragment
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:name="com.example.user.unchained.FooterHome"
    android:layout_alignParentBottom="true"
    android:id="@+id/foo"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    tools:layout="@layout/footer_home" />


 </RelativeLayout>

The Footer Layout XML.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#272822"
android:id="@+id/homeFooter"
tools:context="com.example.user.unchained.FooterHome">


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="What's New ?"
android:textSize="16dip"
android:layout_marginTop="12dip"
android:layout_marginLeft="10dip"
android:drawableLeft="@drawable/status"
android:id="@+id/watsN"
android:textColor="@color/connexion_button"
android:layout_gravity="left|top" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text=" | "
    android:textSize="25dip"
    android:layout_marginTop="6dip"
    android:layout_marginLeft="145dip"
    android:textColor="@color/connexion_button"
    android:layout_gravity="left|top" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Check In"
    android:textSize="16dip"
    android:layout_marginTop="12dip"
    android:layout_marginLeft="165dip"
    android:drawableLeft="@drawable/checkin"
    android:id="@+id/checkIn"
    android:textColor="@color/connexion_button"
    android:layout_gravity="left|top" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text=" | "
    android:textSize="25dip"
    android:layout_marginTop="6dip"
    android:layout_marginLeft="265dip"
    android:textColor="@color/connexion_button"
    android:layout_gravity="left|top" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text=" Picture"
    android:textSize="16dip"
    android:layout_marginTop="12dip"
    android:layout_marginLeft="290dip"
    android:drawableLeft="@drawable/camera"
    android:id="@+id/postPic"
    android:textColor="@color/connexion_button"
    android:layout_gravity="left|top" />

 </FrameLayout>
Karimx
  • 73
  • 1
  • 11

1 Answers1

0

Your error message says: "Duplicate id 0x7f070084..." That makes me think you cannot add the same fragment twice if the root of your fragment has an id.

It's just a guess, but try it without the android:id attributes on the root element.

update

See if you can find out which ids the error message is talking about. Check your R class. It is auto-generated from the layout xml files where it generates unique numbers for each id that you add with the "@+id/some_name" notation.

The error message mentions a problem with id 0x7f070084 or id 0x7f070082. It doesn't mention them by name which would probably give you a better hint where to look for the problem.

But you can look up the names in the auto-generated R class. On Android Studio you can find the R class in the following path: app/build/generated/source/r/debug/com/example/user/unchained/debug. I don't know if Eclipse uses a different path, but I'm sure you can figure it out.

Open the R.java file and search for the id numbers that are mentioned in your error message.

Rob Meeuwisse
  • 2,847
  • 1
  • 17
  • 21