title: How to inflate LinearLayout in a fragment?
body: <p>I want to inflate a <code>LinearLayout</code> into a fragment in the "onCreateView" method. But I have always the same error:</p>
  
  <pre><code>"android.view.InflateException: Binary XML file line #7: Error inflating class fragment"
  </code></pre>
  
  <p>I am using the <code>android.support.v4.app.FragmentActivity</code> in a <code>"libs"</code> folder.</p>
  
  <p>Main activity:</p>
  
  <pre><code>public class GeofranceDeptActivity extends FragmentActivity{
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dept);
  
      }
  }
  </code></pre>
  
  <p>The main xml file <code>dept</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
      &lt;fragment class="dauran.geofrance.DeptFragment"
              android:id="@+id/depts" android:layout_weight="1"
              android:layout_width="0px"
              android:layout_height="match_parent"&gt; 
              &lt;/fragment&gt;
  
      &lt;FrameLayout android:id="@+id/detailsdept" android:layout_weight="1"
              android:layout_width="0px"
              android:layout_height="match_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The class for the fragment <code>DeptFragment</code>:</p>
  
  <pre><code>public class DeptFragment extends Fragment implements OnTouchListener{
  
      Context mContext = getActivity();
  
      boolean mDualPane;
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          if (container == null) {
                return null;
              }
  
      return (LinearLayout)inflater.inflate(R.layout.dept_fragment, container, false);
          }
  
  
      @Override
      public void onActivityCreated(Bundle savedState) {
          ................etc
  </code></pre>
  
  <p>The xml file <code>dept_fragment</code> that I want to inflate :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="vertical" &gt;
      &lt;ImageView
          android:id="@+id/targetDeptImage"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:src="@drawable/region_france_grand" /&gt;
  
      &lt;ImageView
          android:id="@+id/cacheDeptImage"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:src="@drawable/region_france_grand" /&gt;
      &lt;Spinner
          android:id="@+id/sDepartement"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignRight="@+id/targetImage" /&gt;
  
  &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The <code>Logcat</code>:</p>
  
  <pre><code>06-26 19:02:27.940: E/AndroidRuntime(11993): FATAL EXCEPTION: main
  06-26 19:02:27.940: E/AndroidRuntime(11993): java.lang.RuntimeException: Unable to start activity ComponentInfo{dauran.geofrance/dauran.geofrance.GeofranceDeptActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.os.Handler.dispatchMessage(Handler.java:99)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.os.Looper.loop(Looper.java:137)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.ActivityThread.main(ActivityThread.java:4424)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at java.lang.reflect.Method.invokeNative(Native Method)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at java.lang.reflect.Method.invoke(Method.java:511)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at dalvik.system.NativeStart.main(Native Method)
  06-26 19:02:27.940: E/AndroidRuntime(11993): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.Activity.setContentView(Activity.java:1835)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at dauran.geofrance.GeofranceDeptActivity.onCreate(GeofranceDeptActivity.java:10)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.Activity.performCreate(Activity.java:4465)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    ... 11 more
  06-26 19:02:27.940: E/AndroidRuntime(11993): Caused by: java.lang.IllegalStateException: Fragment dauran.geofrance.DeptFragment did not create a view.
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:293)
  06-26 19:02:27.940: E/AndroidRuntime(11993):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
  </code></pre>