title: Android - Error inflating class fragment
body: <p>I have an activity managing a list of fragments. A new fragment I added is extending ListFragmet instead of Fragment, and I added it in the activity xml layout file as the other fragments. I'm getting an InflatingException from at this file at the row where I declare the ListFragment. What is wrong with this declaration?</p>
  
  <p>Activity XML</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="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
      &lt;fragment android:name="com.example.foodexp01b.HomeFragment"
            android:id="@+id/homeFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" /&gt;
      &lt;fragment android:name="com.example.foodexp01b.LoginFragment"
            android:id="@+id/loginFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" /&gt;
      &lt;fragment android:name="com.example.foodexp01b.SettingsFragment"
            android:id="@+id/settingsFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" /&gt;
  
      &lt;fragment android:name="com.example.foodexp01b.DestinationFragment"
            android:id="@+id/destinationFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" /&gt;
      &lt;fragment
            android:id="@+id/mapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="com.google.android.gms.maps.SupportMapFragment"/&gt;
  
      &lt;fragment android:name="com.example.foodexp01b.RestaurantFragment"
            android:id="@+id/restaurantFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" /&gt;
  
      &lt;fragment android:name="com.example.foodexp01b.FavoritesFragment"
            android:id="@+id/favoritesFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Activity OnCreate code</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          uiHelper = new UiLifecycleHelper(this, callback);
          uiHelper.onCreate(savedInstanceState);
  
          FragmentManager fm = getSupportFragmentManager();
          fragments[LOGIN] = fm.findFragmentById(R.id.loginFragment);
          fragments[HOME] = fm.findFragmentById(R.id.homeFragment);
          fragments[SETTINGS] = fm.findFragmentById(R.id.settingsFragment);
          fragments[SETTINGS].getView().findViewById(R.id.back_button1)
          .setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View arg0) {
                  currentFragment = HOME;
                  showFragment(HOME, false);
              }
          });
          fragments[DESTINATIONS] = fm.findFragmentById(R.id.destinationFragment);
          fragments[DESTINATIONS].getView().findViewById(R.id.back_button2)
          .setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View arg0) {
                  currentFragment = HOME;
                  showFragment(HOME, false);
              }
          });
          fragments[MAP] = fm.findFragmentById(R.id.mapFragment);
          fragments[RESTAURANT] = fm.findFragmentById(R.id.restaurantFragment);
          fragments[RESTAURANT].getView().findViewById(R.id.restaurant_back_button)
          .setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View arg0) {
                  currentFragment = MAP;
                  showFragment(MAP, false);
              }
          });
          fragments[FAVORITES].getView().findViewById(R.id.favoritesFragment);
          FragmentTransaction transaction = fm.beginTransaction();
          for(int i = 0; i &lt; fragments.length; i++) {
              transaction.hide(fragments[i]);
          }
          transaction.commit();
      }
  </code></pre>
  
  <p>FavoritesFragment OnCreateView code</p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, 
              ViewGroup container, Bundle savedInstanceState) {
          super.onCreateView(inflater, container, savedInstanceState);
          View view = inflater.inflate(android.R.layout.simple_list_item_1, container, false);
          favorites = new ArrayList&lt;String&gt;();
          setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(),android.R.layout.simple_list_item_1, favorites));
  
          getListView().setOnItemClickListener(new OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,long id) {
                  }
              });
          return view;
      }
  </code></pre>
  
  <p>Log</p>
  
  <pre><code>06-30 20:17:53.609: E/AndroidRuntime(675): FATAL EXCEPTION: main
  06-30 20:17:53.609: E/AndroidRuntime(675): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.foodexp01b/com.example.foodexp01b.MainActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class fragment
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2063)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2088)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.ActivityThread.access$600(ActivityThread.java:134)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.os.Handler.dispatchMessage(Handler.java:99)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.os.Looper.loop(Looper.java:137)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.ActivityThread.main(ActivityThread.java:4744)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at java.lang.reflect.Method.invokeNative(Native Method)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at java.lang.reflect.Method.invoke(Method.java:511)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at dalvik.system.NativeStart.main(Native Method)
  06-30 20:17:53.609: E/AndroidRuntime(675): Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class fragment
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.Activity.setContentView(Activity.java:1867)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at com.example.foodexp01b.MainActivity.onCreate(MainActivity.java:118)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.Activity.performCreate(Activity.java:5008)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2027)
  06-30 20:17:53.609: E/AndroidRuntime(675):  ... 11 more
  06-30 20:17:53.609: E/AndroidRuntime(675): Caused by: java.lang.IllegalStateException: Content view not yet created
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at com.example.foodexp01b.FavoritesFragment.onCreateView(FavoritesFragment.java:63)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
  06-30 20:17:53.609: E/AndroidRuntime(675):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
  06-30 20:17:53.609: E/AndroidRuntime(675):  ... 21 more
  </code></pre>