title: App Crashing when calling a Fragment from an Activity
body: <p>I'm developing an app where I have a fragment as my home page. I'm currently trying to call that fragment from an activity but unfortunately it is crashing. I had even implemented the FragmentTransaction and it still doesnt want to pick it up. </p>
  
  <p>logcat</p>
  
  <pre class="lang-none prettyprint-override"><code>05-02 22:22:40.331 5927-5927/com.example.treycoco.calorietracker E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.treycoco.calorietracker, PID: 5927
  java.lang.NullPointerException: Attempt to invoke virtual method'    android.support.v4.app.FragmentTransactio android.support.v4.app.FragmentTransaction.replace(int, android.support.v4.app.Fragment)' on a null object reference at com.example.treycoco.calorietracker.CalorieDetails$1$1.onClick(CalorieDetails.java:79)
      at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:158)
      at android.app.ActivityThread.main(ActivityThread.java:7229)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
  </code></pre>
  
  <p>update logcat</p>
  
  <pre><code>          example.treycoco.calorietracker E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                   Process: com.example.treycoco.calorietracker, PID: 19224
                                                                                   java.lang.IllegalArgumentException: No view found for id 0x7f0e0080 (com.example.treycoco.calorietracker:id/FragmentHolder) for fragment FragmentHome{d567f7e #0 id=0x7f0e0080}
                                                                                       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)
                                                                                       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
                                                                                       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
                                                                                       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
                                                                                       at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
                                                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                       at android.os.Looper.loop(Looper.java:158)
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
  </code></pre>
  
  <p>caloriedetails.java</p>
  
  <pre><code>   public class CalorieDetails extends AppCompatActivity {
  
     private TextView foodName, calories, dateTaken;
     private Button shareButton;
     private int foodId;
     private Button deleteButton;
  
     private android.support.v4.app.FragmentManager fragmentManager;
     private FragmentTransaction fragmentTransaction;
  
  
        @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_calorie_details);
  
      foodName = (TextView) findViewById(R.id.detsFoodName);
      calories = (TextView) findViewById(R.id.detscaloriesValue);
      dateTaken = (TextView) findViewById(R.id.detsDateText);
  
  
      deleteButton = (Button) findViewById(R.id.deleteButton);
  
  
      Food food = (Food) getIntent().getSerializableExtra("userObj");
  
      foodName.setText(food.getFoodName());
      calories.setText(String.valueOf(food.getCalories()));
      dateTaken.setText(food.getRecordDate());
  
  
      foodId = food.getFoodId();
        foodName.setTextColor(Color.WHITE);
        dateTaken.setTextColor(Color.WHITE);
      calories.setTextSize(34.9f);
      calories.setTextColor(Color.WHITE);
  
  
  
      deleteButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              //TODO: put delete functionality here
              android.support.v7.app.AlertDialog.Builder alert = new 
         android.support.v7.app.AlertDialog.Builder(CalorieDetails.this);
              alert.setTitle("Delete?");
              alert.setMessage("Are you sure you want to delete this item?");
              alert.setNegativeButton("No", null);
              alert.setPositiveButton("Yes", new 
         DialogInterface.OnClickListener() {
  
  
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
  
                      DatabaseHandler dba = new 
          DatabaseHandler(getApplicationContext());
                      dba.deleteFood(foodId);
  
                      Toast.makeText(CalorieDetails.this, "Food Item 
        Deleted!", Toast.LENGTH_SHORT).show();
  
  
  
                      FragmentHome fragmentHome = new FragmentHome()
                      fragmentTransaction =  
                     getSupportedFragmentManager().beginTransaction();
  
                      fragmentTransaction.replace(R.id.FragmentHolder, 
          fragmentHome);
                      fragmentTransaction.commit();
  
  
  
                      CalorieDetails.this.finish();
  
                  }
              });
  
              alert.show();
  
          }
      });
  }
  }
  </code></pre>
  
  <p>caloriedetails.xml</p>
  
  <pre><code>  &lt;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:paddingLeft="@dimen/activity_horizontal_margin"
              android:paddingRight="@dimen/activity_horizontal_margin"
              android:paddingTop="@dimen/activity_vertical_margin"
              android:paddingBottom="@dimen/activity_vertical_margin"
  
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
         tools:context=".CalorieDetails"
         android:background="@drawable/imgbackground2"
       style="@style/AppTheme"
  
        &gt;
  
  
  &lt;ImageView
      android:id="@+id/logo"
      android:src="@drawable/weight"
      android:layout_centerHorizontal="true"
      android:layout_width="180dp"
      android:layout_height="180dp" /&gt;
  
  
  &lt;LinearLayout
      android:id="@+id/layout"
  
      android:elevation="4dp"
      android:orientation="vertical"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/logo"
      android:layout_centerHorizontal="true"&gt;
  
      &lt;TextView
          android:id="@+id/detsFoodName"
          android:elevation="4dp"
          android:text="dkdad"
          android:textSize="19sp"
          android:textStyle="bold"
          android:layout_marginTop="18dp"
          android:layout_gravity="center"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  
  
      &lt;TextView
          android:id="@+id/detsCaloriesTitle"
          android:text="Calories:"
          android:textSize="18sp"
          android:layout_marginTop="18dp"
          android:layout_gravity="center_horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;TextView
          android:id="@+id/detscaloriesValue"
          android:text="200"
          android:textSize="18sp"
          android:layout_marginTop="18dp"
          android:layout_gravity="center_horizontal"
          android:textStyle="bold"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;TextView
          android:id="@+id/detsDateText"
          android:text="Consumed on..."
          android:textStyle="italic"
          android:textSize="14sp"
          android:layout_marginTop="14dp"
          android:layout_gravity="center_horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;Button
          android:id="@+id/deleteButton"
          android:text="DELETE"
          android:textColor="#ffff"
          android:textStyle="bold"
          android:layout_marginTop="20dp"
          android:layout_gravity="center_horizontal"
          android:layout_width="200dp"
          android:background="@color/colorBackground2"
          android:layout_height="wrap_content" /&gt;
  
  
  
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>