@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fex_detail);

    // Don't show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);

    // savedInstanceState is non-null when there is fragment state
    // saved from previous configurations of this activity
    // (e.g. when rotating the screen from portrait to landscape).
    // In this case, the fragment will automatically be re-added
    // to its container so we don't need to manually add it.
    // For more information, see the Fragments API guide at:
    //
    // http://developer.android.com/guide/components/fragments.html
    //
    if (savedInstanceState == null) {
      // Create the detail fragment and add it to the activity
      // using a fragment transaction.
      Bundle arguments = new Bundle();
      arguments.putSerializable(
          FExDetailFragment.ARG_FEX, getIntent().getSerializableExtra(FExDetailFragment.ARG_FEX));
      arguments.putSerializable(
          FExDetailFragment.ARG_WORKOUT,
          getIntent().getSerializableExtra(FExDetailFragment.ARG_WORKOUT));
      FExDetailFragment fragment = new FExDetailFragment();
      fragment.setArguments(arguments);
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.exercise_detail_container, fragment)
          .commit();
    }
  }
  /**
   * Callback method from {@link FExListFragment.Callbacks} indicating that the item with the given
   * ID was selected.
   */
  @Override
  public void onItemSelected(FitnessExercise ex) {
    if (mTwoPane) {
      // In two-pane mode, show the detail view in this activity by
      // adding or replacing the detail fragment using a
      // fragment transaction.
      Bundle arguments = new Bundle();
      arguments.putSerializable(FExDetailFragment.ARG_FEX, ex);
      arguments.putSerializable(FExDetailFragment.ARG_WORKOUT, mWorkout);
      FExDetailFragment fragment = new FExDetailFragment();
      fragment.setArguments(arguments);
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.exercise_detail_container, fragment)
          .commit();

    } else {
      // In single-pane mode, simply start the detail activity
      // for the selected item ID.
      Intent detailIntent = new Intent(this, FExDetailActivity.class);
      detailIntent.putExtra(FExDetailFragment.ARG_FEX, ex);
      detailIntent.putExtra(FExDetailFragment.ARG_WORKOUT, mWorkout);
      startActivityForResult(detailIntent, FExListActivity.RESULT_WORKOUT);
    }
  }