title: android.support.v4.app.FragmentManager OR android.app.FragmentManager?
body: <p>I'm learning Android development. I get stuck at something that should be very easy.</p>
  
  <p>Im creating an App with one Activity, 2 fragments and 1 interface.</p>
  
  <pre><code>android:minSdkVersion="11"
  android:targetSdkVersion="19
  </code></pre>
  
  <p>So in the main activity Im trying to create a reference to Fragment B using the manager. I get stuck here, because Eclispse is telling me to change some things (see below):</p>
  
  <p>My intension:`  </p>
  
  <pre><code>@Override
      public void respond(int i) {
          // TODO Auto-generated method stub
  
      FragmentManager manager =getFragmentManager();
      FragmentB f2= (FragmentB) manager.findFragmentById(R.id.fragment2);
  
  }`
  </code></pre>
  
  <p>If I do it this whay I get the error messages and need to perform some changes. After the changes the code looks like this (and I still can't reach FragmentB):</p>
  
  <pre><code>    @Override
  public void respond(int i) {
      // TODO Auto-generated method stub
  
      android.app.FragmentManager manager =getFragmentManager();
      android.app.Fragment f2=  manager.findFragmentById(R.id.fragment2);
  
  }
  </code></pre>
  
  <p>For extra details I'll put here also the import header of the Activity:</p>
  
  <pre><code>  package com.example.modular_ui;
  
  import android.support.v7.app.ActionBarActivity;
  import android.support.v7.app.ActionBar;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.os.Build;
  
  public class MainActivity extends Activity implements Communicator{....
  </code></pre>
  
  <p>What am I missing here? the whole support.v4 /support.v7 thing is a little confusing for rookies.</p>
  
  <p>EDIT: 
  After changing to:</p>
  
  <pre><code>    import android.app.Fragment;
  import android.app.FragmentManager;
  </code></pre>
  
  <p>AND extending FragmentActivity I still can't create a reference to FragmentB:</p>
  
  <pre><code>@Override
  public void respond(int i) {
      // TODO Auto-generated method stub
  
  FragmentManager man = getFragmentManager();
  FragmentB b = man.findFragmentById(R.id.fragment2);
  </code></pre>
  
  <p>}</p>
  
  <p>As Requested I've posted the FragmentB code:</p>
  
  <pre><code>package com.example.modular_ui;
  
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  
  public class FragmentB extends Fragment {
  
  TextView text;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      return inflater.inflate(R.layout.fragment_b, container);
  }
  
  @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onActivityCreated(savedInstanceState);
          text = (TextView) getActivity().findViewById(R.id.textView1);
      }
  </code></pre>
  
  <p>Main XML</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.modular_ui.MainActivity"
      tools:ignore="MergeRootFrame" &gt;
  
      &lt;fragment
          android:id="@+id/fragment1"
          android:name="com.example.modular_ui.FragmentA"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
      &lt;fragment
          android:id="@+id/fragment2"
          android:name="com.example.modular_ui.FragmentB"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/fragment1"
          android:layout_marginTop="54dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>