title: Inflate fragment from activity
body: <p>Here is my activity class. I am trying to inflate fragment to this activity.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
          ft.replace(R.id.fg1, new ButtonsFragment());
          ft.commit();
      }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:id="@+id/a_layout"
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;fragment
          android:layout_width="match_parent"
          android:layout_height="80dp"
          android:layout_margin="10dp"
          android:id="@+id/fg1"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>ButtonsFragment.java</strong></p>
  
  <pre><code>public class ButtonsFragment extends Fragment {
  
      Button b1,b2,b3;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
      {
          super.onCreateView(inflater,container,savedInstanceState);
  
         View v = inflater.inflate(R.layout.fragment_buttons,container,false);
  
          b2 = (Button)v.findViewById(R.id.b2);
          b1 = (Button)v.findViewById(R.id.b1);
          b3 = (Button)v.findViewById(R.id.b3);
          return v;
      }
  }
  </code></pre>
  
  <p><strong>fragment_buttons.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="com.example.iiitb.patientdoctormanagementsystem.ButtonsFragment"&gt;
  
   &lt;LinearLayout
          android:id="@+id/ll"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;Button
              android:textAllCaps="false"
              android:text="Past Appointments"
              android:id="@+id/b1"
              android:layout_width="0dp"
              android:layout_weight="1"
              android:layout_height="wrap_content" /&gt;
  
          &lt;Button
              android:textAllCaps="false"
              android:text="Todays Appointments"
              android:id="@+id/b2"
              android:layout_width="0dp"
              android:layout_weight="1"
              android:layout_height="wrap_content" /&gt;
  
          &lt;Button
              android:textAllCaps="false"
              android:text="Upcoming Appointments"
              android:id="@+id/b3"
              android:layout_width="0dp"
              android:layout_weight="1"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>But I am getting this exception:  </p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iiitb.patientdoctormanagementsystem/com.example.iiitb.patientdoctormanagementsystem.MainActivity}: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class fragment 
  </code></pre>
  
  <p>PLEASE HELP!!</p>