title: Android MapView Loading Black Screen
body: <p>Hi everyone I have an Activity which is loading after I click on an Item inside my Listview.</p>
  
  <p>This activity shows the location inside a MapView like this:</p>
  
  <pre><code>&lt;FrameLayout
                  android:id="@+id/mapContainer"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_toEndOf="@+id/imageView"
                  android:layout_above="@+id/button"
                  android:layout_below="@+id/imageView"
                  android:layout_alignParentStart="true"
                  android:layout_marginTop="10dp" &gt;
  
                  &lt;TextView
                      android:id="@+id/loading"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"
                      android:text="Loading Map..." /&gt;
  
              &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>The Problem is, that I want to show the Map to the User later on if he/she clicks on a button.</p>
  
  <p>But the Activity is loading very slow and even has a black blank screen before showing anything. This looks very unprofessional, and seems wrong.</p>
  
  <p>I tried making the MapView <strong>invisible</strong> first and show it when user hits the button, but it is loading when the activity starts.</p>
  
  <p>I'am  trying following code:</p>
  
  <pre><code>protected void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_single_event);
  
          mapView = new MapView(SingleEvent.this);
          mapView.onCreate(savedInstanceState);
          com.google.android.gms.maps.MapView.LayoutParams mapParams = new com.google.android.gms.maps.MapView.LayoutParams(com.google.android.gms.maps.MapView.LayoutParams.MATCH_PARENT,220);
          mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
          mapContainer.addView(mapView, mapParams);
  </code></pre>
  
  <p>This one is working it is showing the map, but the activity is loading to long with a black blank screen, until my activity is loaded.</p>
  
  <p><img src="https://i.stack.imgur.com/rPGuh.png" alt="enter image description here"></p>
  
  <p>Is there any way to <strong>first</strong> load the activity and after that load the MapView on a button click?</p>
  
  <p>I'am trying to do something like this:</p>
  
  <pre><code>Handler handler = new Handler();
  
      handler.postDelayed(new Runnable() {
                  @Override
                  public void run() {
  
              mapView = new MapView(SingleEvent.this);
              mapView.onCreate(savedInstanceState);
              com.google.android.gms.maps.MapView.LayoutParams mapParams = new com.google.android.gms.maps.MapView.LayoutParams(com.google.android.gms.maps.MapView.LayoutParams.MATCH_PARENT,220);
              mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
              mapContainer.addView(mapView, mapParams);
  
                  }
              },1000);
  </code></pre>
  
  <p>But with that code, the Map isnt loading its only showing the grey blank grid.
  I think its because of the <strong>savedInstanceState</strong> but maybe there is a work around?</p>
  
  <p>I tried to save the Bundle savedInstanceState, loading like above.</p>