title: Loading android layout from xml
body: <p>I would like to load the layout from the xml file, I tried:</p>
  
  <pre><code>View view = inflater.inflate(R.layout.map_cameras_fragment, container, false);  
  </code></pre>
  
  <p>but it just shows this: </p>
  
  <pre><code>java.lang.NullPointerException at maps.z.r.onResume(Unknown Source)...
  </code></pre>
  
  <p>Here is my whole code (I'm using <a href="https://code.google.com/p/android-maps-extensions/" rel="nofollow">android maps extensions</a>):</p>
  
  <pre><code>public class MapCamerasFragment extends SupportMapFragment {
  
  private GoogleMap mMap = null;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container, 
                           Bundle savedInstanceState) 
  {    
      View view = inflater.inflate(R.layout.map_cameras_fragment, container, false);  
      SupportMapFragment myFrag = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.mapChooseCameras);
      mMap = myFrag.getExtendedMap();
  
      MarkerGenerator.addMarkersInWorld(mMap);
      mMap.setClustering(new ClusteringSettings().iconDataProvider(new DemoIconProvider(getResources())).addMarkersDynamically(true));
  
      return view;
  }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>LOGCAT</strong>:</p>
  
  <pre><code>E/AndroidRuntime(3673): FATAL EXCEPTION: main
  E/AndroidRuntime(3673): java.lang.NullPointerException
  at maps.z.r.onResume(Unknown Source)
  at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:115)
  at android.os.Binder.transact(Binder.java:297)
  at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onResume(Unknown Source)
  at com.google.android.gms.maps.SupportMapFragment$a.onResume(Unknown Source)
  at com.google.android.gms.internal.e$1.a(Unknown Source)
  at com.google.android.gms.internal.e.a(Unknown Source)
  at com.google.android.gms.internal.e.onResume(Unknown Source)
  at com.google.android.gms.maps.SupportMapFragment.onResume(Unknown Source)
  at android.support.v4.app.Fragment.performResume(Fragment.java:1503)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
  at android.support.v4.app.FragmentManagerImpl.performPendingDeferredStart(FragmentManager.java:807)
  at android.support.v4.app.FragmentManagerImpl.startPendingDeferredFragments(FragmentManager.java:1112)
  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1461)
  at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
  at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
  at android.support.v4.view.ViewPager.populate(ViewPager.java:1012)
  at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
  at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
  at android.view.View.measure(View.java:12723)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
  at android.view.View.measure(View.java:12723)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
  at android.view.View.measure(View.java:12723)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
  at android.view.View.measure(View.java:12723)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
  at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092)
  at android.view.View.measure(View.java:12723)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
  at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4424)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p><strong>map_cameras_fragment.xml</strong></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:orientation="vertical" &gt;
  
      &lt;fragment
          android:id="@+id/mapChooseCameras"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          class="pl.mg6.android.maps.extensions.SupportMapFragment"/&gt;
        &lt;Button android:id="@+id/googlemaps_select_location"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:text="Select"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>I have been trying this</p>
  
  <pre><code>  ...
    View view = inflater.inflate(R.layout.map_cameras_fragment, container, false);       
    super.onCreateView(inflater, container, savedInstanceState);
    mMap = super.getExtendedMap();
    MarkerGenerator.addMarkersInWorld(mMap);
    mMap.setClustering(new ClusteringSettings().iconDataProvider(new DemoIconProvider(getResources())).addMarkersDynamically(true));  
    return view;
    ...
  </code></pre>
  
  <p>There is no exception but markers are not visible. It seems that there are two views...
  Do you know how to fix it?</p>