title: Error inflating class fragment error
body: <p>I have a Main activity with two master detail Fragments.I am trying to implement like <a href="http://developer.android.com/guide/practices/tablets-and-handsets.html#Fragments" rel="nofollow">"Multiple fragments, multiple activities"</a> method.</p>
  
  <p><strong>layout</strong> folder
  <strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;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"
      tools:context=".MoneyActivity"
      android:id="@+id/fragment_container" &gt;
   &lt;fragment class="com.mysite.money.AFragment"
                android:id="@+id/AFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/&gt;
   &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>layout-large</strong> folder <strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout 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"
      tools:context=".MoneyActivity"
      android:id="@+id/fragment_container"
      android:orientation="horizontal" &gt;
  
  
     &lt;fragment class="com.mysite.money.AFragment"
                android:id="@+id/AFragment"
                android:layout_width="@dimen/action_bar_title_text_size"
                android:layout_height="match_parent"/&gt;
  
     &lt;fragment class="com.mysite.money.BFragment"
                android:id="@+id/BFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/&gt;
  
  
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>I got error like below(when run on tablet-layout-large):</strong></p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mysite.money/com.mysite.money.MoneyActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
  </code></pre>
  
  <p>I checked class names of fragments properly.</p>
  
  <p><strong>I think i got error BFragment</strong></p>
  
  <p><strong>BFragment:</strong>
      public class BFragment extends SherlockFragment {</p>
  
  <pre><code>    String selectedItem="";
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          int size = getArguments().size();
          if(size&gt;0)
          {
              selectedItem = getArguments().getString("position").toString();
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
          TextView textView=new TextView(inflater.getContext());
          textView.setText("Selected Item-&gt;"+selectedItem);
          return textView;
      }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>OnItemSelected in my mainActivity(Associated with fragment A)</strong></p>
  
  <pre><code>**@Override
      public void onItemSelected(String id) {
            BFragment displayFrag = (BFragment) getSupportFragmentManager().findFragmentById(new BFragment().getId());
          if (displayFrag == null) {
              // DisplayFragment (Fragment B) is not in the layout (handset layout),
              // so start DisplayActivity (Activity B)
              // and pass it the info about the selected item
              Intent intent = new Intent(this, BActivity.class);
              intent.putExtra("position", id);
              Log.i("innodea", "position-&gt;"+id);
              startActivity(intent);
  
          } else {
              // DisplayFragment (Fragment B) is in the layout (tablet layout),
              // so tell the fragment to update
              //displayFrag.updateContent(id);
          }
      }**
  </code></pre>
  
  <p><strong>AFragment:</strong></p>
  
  <pre><code>public class AFragment extends SherlockListFragment {
  
      private View inflate;
      private Callbacks mCallbacks = sDummyCallbacks;
      private int mActivatedPosition= ListView.INVALID_POSITION;
      private static final String STATE_ACTIVATED_POSITION = "activated_position";
  
      public interface Callbacks {
          public void onItemSelected(String id);
      }
  
      /**
       * A dummy implementation of the {@link Callbacks} interface that does
       * nothing. Used only when this fragment is not attached to an activity.
       */
      private static Callbacks sDummyCallbacks = new Callbacks() {
          public void onItemSelected(String id) {
          }
      };
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          // Activities containing this fragment must implement its callbacks.
          if (!(activity instanceof Callbacks)) {
              throw new IllegalStateException(
                      "Activity must implement fragment's callbacks.");
          }
  
          mCallbacks = (Callbacks) activity;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setListAdapter(new ArrayAdapter&lt;DummyContent.DummyItem&gt;(getActivity(),android.R.layout.simple_list_item_activated_1,android.R.id.text1, DummyContent.ITEMS));
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
  
          // Restore the previously serialized activated item position.
          if (savedInstanceState != null
                  &amp;&amp; savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
              setActivatedPosition(savedInstanceState
                      .getInt(STATE_ACTIVATED_POSITION));
          }
      }
  
  
  
      @Override
      public void onDetach() {
          super.onDetach();
  
          // Reset the active callbacks interface to the dummy implementation.
          mCallbacks = sDummyCallbacks;
      }
  
      @Override
      public void onListItemClick(ListView listView, View view, int position,long id) {
          super.onListItemClick(listView, view, position, id);
  
          // Notify the active callbacks interface (the activity, if the
          // fragment is attached to one) that an item has been selected.
          mCallbacks.onItemSelected(DummyContent.ITEMS.get(position).id);
      }
  
      @Override
      public void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          if (mActivatedPosition != ListView.INVALID_POSITION) {
              // Serialize and persist the activated item position.
              outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
          }
      }
  
      /**
       * Turns on activate-on-click mode. When this mode is on, list items will be
       * given the 'activated' state when touched.
       */
      public void setActivateOnItemClick(boolean activateOnItemClick) {
          // When setting CHOICE_MODE_SINGLE, ListView will automatically
          // give items the 'activated' state when touched.
          getListView().setChoiceMode(
                  activateOnItemClick ? ListView.CHOICE_MODE_SINGLE
                          : ListView.CHOICE_MODE_NONE);
      }
  
      private void setActivatedPosition(int position) {
          if (position == ListView.INVALID_POSITION) {
              getListView().setItemChecked(mActivatedPosition, false);
          } else {
              getListView().setItemChecked(position, true);
          }
  
          mActivatedPosition = position;
      }
  
  }
  </code></pre>