title: Creating a custom Fragment with full screen map
body: <p>I'd like to build a <code>Fragment</code> which consists of a full screen map overlaid with other views (A <code>ViewPager</code>, <code>EditText</code>, and the like). I've thought of two different options:</p>
  
  <ol>
  <li>Create a <code>Fragment</code> with a <code>MapView</code> near the root of the layout and set it to <code>match_parent</code>, then use other <code>View</code>'s as normal.</li>
  <li>Subclass <code>MapFragment</code>.</li>
  </ol>
  
  <p>I've subclassed <code>MapFragment</code>:</p>
  
  <pre><code>public class ListMapFragment extends MapFragment {
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          return super.onCreateView(inflater, container, savedInstanceState);
      }
  }
  </code></pre>
  
  <p>Displaying this fragment works as normal and the map takes up the entire fragment. However, I would like to display various views as described above over the map. If I try to inflate and return a view (as you would with a normal <code>Fragment</code>) by instead returning a view, a NPE occurs:</p>
  
  <pre><code>public class ListMapFragment extends MapFragment {
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.fragment_list_map, container, false);
          return view; 
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void maps.ad.y.v()' on a null object reference</p>
  </blockquote>
  
  <p>If I try calling the supers method before returning a view, the layout is loaded, but the map is not:</p>
  
  <pre><code>public class ListMapFragment extends MapFragment {
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.fragment_list_map, container, false);
  
          super.onCreateView(inflater, container, savedInstanceState);
  
          return view;
      } 
  </code></pre>
  
  <p>Out of the two options, is one preferred over the other? And if #2 is preferred, what is wrong with the above code?</p>