title: Google Maps API v2 Custom MapFragment + SimpleFragment
body: <p>I need to create a simple application which contain 
  1. Custom MapFragment which can display current location (LocationListener?), two markers, etc.
  2. Simple empty Fragments.</p>
  
  <p>The application must not use support v4 (sdk 11+) / FragmentActivity.</p>
  
  <p>Empty fragment.</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/black" &gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>public class FirstFragment extends Fragment{
  
  public FirstFragment() {
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.first_fragment, container, false);
      return view;
  }
  }
  </code></pre>
  
  <p>Map fragment (try to make it singleton).</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment"/&gt;
  </code></pre>
  
  <p>Class</p>
  
  <pre><code>public class ThirdMapFragment extends MapFragment {
  public static MapFragment instance;
  
  @Override
  public View onCreateView(LayoutInflater arg0, ViewGroup arg1, Bundle arg2) {
      View view;
      view = arg0.inflate(R.layout.map_fragment, arg1, false);
      return view;
  }
  
  public static MapFragment getInstance() {
      if (instance == null) {
          instance = newInstance();
      }
      // NullPointerException in getMap() ???
      // instance.getMap().addMarker(new MarkerOptions().position(new LatLng(41.1, 39)));
      return instance;
  }
  
  @Override
  public void onCreate(Bundle arg0) {
      super.onCreate(arg0);
  }
  }
  </code></pre>
  
  <p>Main activity:</p>
  
  <pre><code>public class ActivityMain extends Activity implements OnClickListener {
  FragmentManager fragmentManager;
  FragmentTransaction transaction;
  FirstFragment firstFragment;
  MapFragment mapFragment;
  
  // Buttons
  Button b4;
  
  int i = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      fragmentManager = getFragmentManager();
      transaction = fragmentManager.beginTransaction();
  
      b4 = (Button) findViewById(R.id.button4);
  
      b1.setOnClickListener(this);
  
      firstFragment = new FirstFragment();
      mapFragment =  ThirdMapFragment.getInstance();
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  
  @Override
  public void onClick(View v) {
      makeTransaction(v.getId());
  }
  
  
  
  private void makeTransaction(int id) {
      i++;
      transaction = fragmentManager.beginTransaction();
      if (i == 1) {
          transaction.replace(R.id.relativeLayout, firstFragment).commit();
      } else if (i == 2) {
          transaction.replace(R.id.relativeLayout, secondFragment).commit();
      } else {
      transaction.replace(R.id.relativeLayout, mapFragment).commit();
          i = 0;
      }
  }
  }
  </code></pre>
  
  <p>R.id.relativeLayout - Layout in main.xml</p>
  
  <p>But I do not see the map (empty screen with zoom buttons) and how to make LocationListener? Thx.</p>