0

I’ve added a fragment to my main layout. But when i lunch it the app crash and the error log show this: android.view.InflateException: Binary XML file line #16: Error inflating class fragment. I think i have do all things right but I don't where is the error :/.

My Main Layout :

<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"
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:id="@+id/homeFooter"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    tools:layout="@layout/footer_home" />

    </RelativeLayout>

My Fragment :

<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="#000"
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>

The Fragment Class :

public class FooterHome extends Fragment {

private OnFragmentInteractionListener mListener;

// TODO: Rename and change types and number of parameters
public static FooterHome newInstance() {
    FooterHome fragment = new FooterHome();

    return fragment;
}
public FooterHome() {
    // Required empty public constructor
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.footer_home, container, false);
}

// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
    if (mListener != null) {
        mListener.onFragmentInteraction(uri);
    }
}

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {
        mListener = (OnFragmentInteractionListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString()
                + " must implement OnFragmentInteractionListener");
    }
}

@Override
public void onDetach() {
    super.onDetach();
    mListener = null;
}

/**
 * This interface must be implemented by activities that contain this
 * fragment to allow an interaction in this fragment to be communicated
 * to the activity and potentially other fragments contained in that
 * activity.
 * <p>
 * See the Android Training lesson <a href=
 * "http://developer.android.com/training/basics/fragments/communicating.html"
 * >Communicating with Other Fragments</a> for more information.
 */
public interface OnFragmentInteractionListener {
    // TODO: Update argument type and name
    public void onFragmentInteraction(Uri uri);
}

}

@Override
public void onDetach() {
    super.onDetach();
    mListener = null;
}

public interface OnFragmentInteractionListener {
    // TODO: Update argument type and name
    public void onFragmentInteraction(Uri uri);
}

}
10
  • post com.example.user.unchained.FooterHome Commented Oct 7, 2014 at 9:53
  • i've update the question body : Commented Oct 7, 2014 at 9:55
  • 1
    Change this "com.example.user.unchained.FooterHome" to com.example.user.unchained.FooterFragment Commented Oct 7, 2014 at 9:58
  • is footerHome sorry i've past the wrong fragment but it is sur is footerHome Commented Oct 7, 2014 at 10:03
  • 1
    OK then post your logcat so that i can figure out clearly what is the problem Commented Oct 7, 2014 at 10:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.