title: Change fragments in Switch Statement
body: <p>I have a <code>FragmentAcivity</code> I am using to create a dynamic UI. I want to be able to replace a fragment that only has text with a fragment that may have to post content online, like to Twitter or a server, based on the intent that the FragmentActivity recieves.</p>
  
  <p>I used a switch (like you see below) and Android Studio tells me it cannot resolve the second <code>add()</code> (where I add postFrag) method on my transaction object. What am I missing? If using a switch is a bad idea, how else can it be done?</p>
  
  <p>'fragView` is the fragment container.</p>
  
  <pre><code>private void showContentInContainer() {
  
      // Get intent to determine next action
      int workType = getIntent().getExtras().getInt(MainActivity.TAG_FRAGWORK);
  
      FragmentManager fragmentManager = getFragmentManager();
      FragmentTransaction transaction = fragmentManager.beginTransaction();
  
      // Add the appropriate frag
      switch (workType) {
          case MainActivity.VIEW_RIGHTS :
              // TODO: Pass a rights fragment
              RightsFragment rightsFrag = new RightsFragment();
              transaction.add(R.id.fragView, rightsFrag);
              break;
          case MainActivity.VIEW_SRA :
              // TODO: Pass a view SRA fragment
              PostFragment postFrag = new PostFragment();
              transaction.add(R.id.fragView, postFrag);
              break;
          default: break;
      }
      transaction.commit(); // publish changes
  }
  </code></pre>
  
  <p><strong>EDIT: Added XML of fragment container view</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;ScrollView
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"&gt;
      &lt;fragment
          android:id="@+id/fragView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/&gt;
  &lt;/ScrollView&gt;
  
  &lt;fragment
      android:id="@+id/adFragment_2"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:name="com.frankbrenyahapps.citisafe.adFragment"
      tools:layout="@layout/fragment_ad"  /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>