title: Android, cardflip animation, fragments not displaying
body: <p>I am having issues with the cardflip animation in Android. I am following their guide and also trying to pick a part the AnimationsDemo to try to understand this. But I have created all the card flip in and outs in XML and the card front and back layout in XML. I keep getting an error message when I try to add the fragment in onCreate. I'm not sure what is triggering the error as the code looks like the example code they use. I've included the error message and jave code below. Thanks for your time.</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
      /**
       * Whether or not we're showing the back of the card (otherwise showing the front).
       */
      private boolean mShowingBack = false;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          if (savedInstanceState == null) {
              getFragmentManager()
              .beginTransaction()
              .add(R.id.container, new CardFrontFragment())
              .commit();
          }else {
              mShowingBack = (getFragmentManager().getBackStackEntryCount() &gt; 0);
          }
  
              /**
              getSupportFragmentManager().beginTransaction()
                      .add(R.id.container, new PlaceholderFragment()).commit();
                      */
      }
  
      private void flipCard() {
          if (mShowingBack) {
              getFragmentManager().popBackStack();
              return;
          }
  
          // Flip to the back.
  
          mShowingBack = true;
  
          // Create and commit a new fragment transaction that adds the fragment for the back of
          // the card, uses custom animations, and is part of the fragment manager's back stack.
  
          getFragmentManager()
                  .beginTransaction()
  
                  // Replace the default fragment animations with animator resources representing
                  // rotations when switching to the back of the card, as well as animator
                  // resources representing rotations when flipping back to the front (e.g. when
                  // the system Back button is pressed).
                  .setCustomAnimations(
                          R.animator.card_flip_right_in, R.animator.card_flip_right_out,
                          R.animator.card_flip_left_in, R.animator.card_flip_left_out)
  
                  // Replace any fragments currently in the container view with a fragment
                  // representing the next page (indicated by the just-incremented currentPage
                  // variable).
                  .replace(R.id.container, new CardBackFragment())
  
                  // Add this transaction to the back stack, allowing users to press Back
                  // to get to the front of the card.
                  .addToBackStack(null)
  
                  // Commit the transaction.
                  .commit();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
  
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
          if (id == R.id.action_settings) {
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
      /**
       * A placeholder fragment containing a simple view.
       */
      public static class PlaceholderFragment extends Fragment {
  
          public PlaceholderFragment() {
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.fragment_main, container,
                      false);
              return rootView;
          }
      }
  
      /**
       * A fragment representing the front of the card.
       */
      public static class CardFrontFragment extends Fragment {
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
              return inflater.inflate(R.layout.card_front, container, false);
          }
      }
  
      /**
       * A fragment representing the back of the card.
       */
      public static class CardBackFragment extends Fragment {
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
              return inflater.inflate(R.layout.card_back, container, false);
          }
      }
  
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, MainActivity.CardFrontFragment) MainActivity.java   /Lab6b/src/you/ca/mohawk/lab6b  line 28 Java Problem
  </code></pre>